1 | #!/bin/sh |
---|
2 | |
---|
3 | # $Id: copyright_cache_test.sh 1364 2011-06-05 00:01:14Z peter $ |
---|
4 | |
---|
5 | # Copyright (C) 2011 Peter Johansson |
---|
6 | # |
---|
7 | # This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
8 | # |
---|
9 | # svndigest is free software; you can redistribute it and/or modify it |
---|
10 | # under the terms of the GNU General Public License as published by |
---|
11 | # the Free Software Foundation; either version 3 of the License, or |
---|
12 | # (at your option) any later version. |
---|
13 | # |
---|
14 | # svndigest is distributed in the hope that it will be useful, but |
---|
15 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | # General Public License for more details. |
---|
18 | # |
---|
19 | # You should have received a copy of the GNU General Public License |
---|
20 | # along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | |
---|
22 | required="repo" |
---|
23 | |
---|
24 | . ./init.sh || exit 1 |
---|
25 | |
---|
26 | # exit if cmd fails |
---|
27 | set -e |
---|
28 | |
---|
29 | file=Credits.txt |
---|
30 | cache_dir=$rootdir/alhambra/.svndigest |
---|
31 | cache_file=$cache_dir/${file}.svncopyright-cache |
---|
32 | rm -f $cache_file |
---|
33 | |
---|
34 | # mini config file |
---|
35 | cat > config <<EOF |
---|
36 | [copyright-alias] |
---|
37 | jari = Jari Häkkinen |
---|
38 | peter = Peter Johansson |
---|
39 | EOF |
---|
40 | |
---|
41 | $SVN revert -R $rootdir |
---|
42 | SVNCOPYRIGHT_run 0 -r $rootdir/alhambra --ignore-cache -v --config-file=config |
---|
43 | test -s stderr && exit_fail |
---|
44 | test -r $cache_file || exit_fail |
---|
45 | # check that we cache user name not alias |
---|
46 | grep peter $cache_file || exit_fail |
---|
47 | cp $cache_file cache.txt |
---|
48 | |
---|
49 | cat > correct.txt <<EOF |
---|
50 | Copyright (C) 2006 Jari Häkkinen |
---|
51 | Copyright (C) 2009 Peter Johansson |
---|
52 | EOF |
---|
53 | grep 'Copyright (C)' $rootdir/alhambra/$file > copyright.txt || exit_fail |
---|
54 | diff -u correct.txt copyright.txt || exit_fail |
---|
55 | |
---|
56 | # modify the cache file to allow us to detect that it is used |
---|
57 | sed -i 's/peter/winston/' $cache_file |
---|
58 | # create a config reflecting this name change |
---|
59 | sed 's/peter/winston/' config > config2 |
---|
60 | |
---|
61 | # copyright update using cache created above |
---|
62 | $SVN revert -R $rootdir |
---|
63 | SVNCOPYRIGHT_run 0 -r $rootdir/alhambra -v --config-file=config2 |
---|
64 | test -s stderr && exit_fail |
---|
65 | grep 'Copyright (C)' $rootdir/alhambra/$file > copyright2.txt || exit_fail |
---|
66 | diff -u correct.txt copyright.txt || exit_fail |
---|
67 | |
---|
68 | diff -u cache.txt $cache_file || exit_fail |
---|
69 | |
---|
70 | exit_success; |
---|