]>
Commit | Line | Data |
---|---|---|
d727f676 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2008 Eric Wong | |
4 | # | |
5 | ||
6 | test_description='git svn authors file tests' | |
7 | ||
8 | . ./lib-git-svn.sh | |
9 | ||
10 | cat > svn-authors <<EOF | |
11 | aa = AAAAAAA AAAAAAA <aa@example.com> | |
12 | bb = BBBBBBB BBBBBBB <bb@example.com> | |
13 | EOF | |
14 | ||
15 | test_expect_success 'setup svnrepo' ' | |
16 | for i in aa bb cc dd | |
17 | do | |
da083d68 | 18 | svn_cmd mkdir -m $i --username $i "$svnrepo"/$i |
d727f676 EW |
19 | done |
20 | ' | |
21 | ||
22 | test_expect_success 'start import with incomplete authors file' ' | |
23 | ! git svn clone --authors-file=svn-authors "$svnrepo" x | |
24 | ' | |
25 | ||
26 | test_expect_success 'imported 2 revisions successfully' ' | |
27 | ( | |
28 | cd x | |
29 | test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 2 && | |
30 | git rev-list -1 --pretty=raw refs/remotes/git-svn | \ | |
31 | grep "^author BBBBBBB BBBBBBB <bb@example\.com> " && | |
32 | git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ | |
33 | grep "^author AAAAAAA AAAAAAA <aa@example\.com> " | |
34 | ) | |
35 | ' | |
36 | ||
37 | cat >> svn-authors <<EOF | |
38 | cc = CCCCCCC CCCCCCC <cc@example.com> | |
39 | dd = DDDDDDD DDDDDDD <dd@example.com> | |
40 | EOF | |
41 | ||
42 | test_expect_success 'continues to import once authors have been added' ' | |
43 | ( | |
44 | cd x | |
45 | git svn fetch --authors-file=../svn-authors && | |
46 | test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 4 && | |
47 | git rev-list -1 --pretty=raw refs/remotes/git-svn | \ | |
48 | grep "^author DDDDDDD DDDDDDD <dd@example\.com> " && | |
49 | git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ | |
50 | grep "^author CCCCCCC CCCCCCC <cc@example\.com> " | |
51 | ) | |
52 | ' | |
53 | ||
54 | test_expect_success 'authors-file against globs' ' | |
da083d68 | 55 | svn_cmd mkdir -m globs --username aa \ |
d727f676 EW |
56 | "$svnrepo"/aa/trunk "$svnrepo"/aa/branches "$svnrepo"/aa/tags && |
57 | git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work && | |
58 | for i in bb ee cc | |
59 | do | |
60 | branch="aa/branches/$i" | |
da083d68 | 61 | svn_cmd mkdir -m "$branch" --username $i "$svnrepo/$branch" |
d727f676 EW |
62 | done |
63 | ' | |
64 | ||
65 | test_expect_success 'fetch fails on ee' ' | |
66 | ( cd aa-work && ! git svn fetch --authors-file=../svn-authors ) | |
67 | ' | |
68 | ||
69 | tmp_config_get () { | |
70 | GIT_CONFIG=.git/svn/.metadata git config --get "$1" | |
71 | } | |
72 | ||
73 | test_expect_success 'failure happened without negative side effects' ' | |
74 | ( | |
75 | cd aa-work && | |
76 | test 6 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" && | |
77 | test 6 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`" | |
78 | ) | |
79 | ' | |
80 | ||
81 | cat >> svn-authors <<EOF | |
82 | ee = EEEEEEE EEEEEEE <ee@example.com> | |
83 | EOF | |
84 | ||
85 | test_expect_success 'fetch continues after authors-file is fixed' ' | |
86 | ( | |
87 | cd aa-work && | |
88 | git svn fetch --authors-file=../svn-authors && | |
89 | test 8 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" && | |
90 | test 8 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`" | |
91 | ) | |
92 | ' | |
93 | ||
e2f8617b EW |
94 | test_expect_success 'fresh clone with svn.authors-file in config' ' |
95 | ( | |
96 | rm -r "$GIT_DIR" && | |
97 | test x = x"$(git config svn.authorsfile)" && | |
98 | HOME="`pwd`" && | |
99 | export HOME && | |
100 | test_config="$HOME"/.gitconfig && | |
101 | unset GIT_CONFIG_NOGLOBAL && | |
102 | unset GIT_DIR && | |
103 | unset GIT_CONFIG && | |
104 | git config --global \ | |
105 | svn.authorsfile "$HOME"/svn-authors && | |
106 | test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" && | |
107 | git svn clone "$svnrepo" gitconfig.clone && | |
108 | cd gitconfig.clone && | |
109 | nr_ex=$(git log | grep "^Author:.*example.com" | wc -l) && | |
110 | nr_rev=$(git rev-list HEAD | wc -l) && | |
111 | test $nr_rev -eq $nr_ex | |
112 | ) | |
113 | ' | |
114 | ||
115 | test_debug 'GIT_DIR=gitconfig.clone/.git git log' | |
116 | ||
d727f676 | 117 | test_done |