]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9138-git-svn-authors-prog.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t9138-git-svn-authors-prog.sh
CommitLineData
36db1edd
ML
1#!/bin/sh
2#
3# Copyright (c) 2009 Eric Wong, Mark Lodato
4#
5
6test_description='git svn authors prog tests'
7
8. ./lib-git-svn.sh
9
01730a3b
JM
10write_script svn-authors-prog "$PERL_PATH" <<-\EOF
11 $_ = shift;
cb427e9e
AH
12 if (s/-hermit//) {
13 print "$_ <>\n";
14 } elsif (s/-sub$//) {
01730a3b
JM
15 print "$_ <$_\@sub.example.com>\n";
16 } else {
17 print "$_ <$_\@example.com>\n";
18 }
36db1edd 19EOF
36db1edd 20
01730a3b
JM
21test_expect_success 'svn-authors setup' '
22 cat >svn-authors <<-\EOF
23 ff = FFFFFFF FFFFFFF <fFf@other.example.com>
24 EOF
25'
36db1edd
ML
26
27test_expect_success 'setup svnrepo' '
28 for i in aa bb cc-sub dd-sub ee-foo ff
29 do
30 svn mkdir -m $i --username $i "$svnrepo"/$i
31 done
01730a3b 32'
36db1edd
ML
33
34test_expect_success 'import authors with prog and file' '
35 git svn clone --authors-prog=./svn-authors-prog \
36 --authors-file=svn-authors "$svnrepo" x
01730a3b 37'
36db1edd
ML
38
39test_expect_success 'imported 6 revisions successfully' '
40 (
cff4243d 41 cd x &&
a4d4e32a
PK
42 git rev-list refs/remotes/git-svn >actual &&
43 test_line_count = 6 actual
36db1edd 44 )
01730a3b 45'
36db1edd
ML
46
47test_expect_success 'authors-prog ran correctly' '
48 (
cff4243d 49 cd x &&
a4d4e32a
PK
50 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
51 grep "^author ee-foo <ee-foo@example\.com> " actual &&
52 git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual &&
53 grep "^author dd <dd@sub\.example\.com> " actual &&
54 git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual &&
55 grep "^author cc <cc@sub\.example\.com> " actual &&
56 git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual &&
57 grep "^author bb <bb@example\.com> " actual &&
58 git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual &&
59 grep "^author aa <aa@example\.com> " actual
36db1edd 60 )
01730a3b 61'
36db1edd
ML
62
63test_expect_success 'authors-file overrode authors-prog' '
64 (
cff4243d 65 cd x &&
a4d4e32a
PK
66 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
67 grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual
36db1edd 68 )
01730a3b 69'
36db1edd 70
d3d7d47e
ML
71git --git-dir=x/.git config --unset svn.authorsfile
72git --git-dir=x/.git config --unset svn.authorsprog
73
cb427e9e
AH
74test_expect_success 'authors-prog imported user without email' '
75 svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
76 (
77 cd x &&
78 git svn fetch --authors-prog=../svn-authors-prog &&
79 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
80 grep "^author gg <> "
81 )
82'
83
84test_expect_success 'imported without authors-prog and authors-file' '
85 svn mkdir -m hh --username hh "$svnrepo"/hh &&
86 (
87 uuid=$(svn info "$svnrepo" |
88 sed -n "s/^Repository UUID: //p") &&
89 cd x &&
90 git svn fetch &&
91 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
92 grep "^author hh <hh@$uuid> "
93 )
94'
95
d3d7d47e
ML
96test_expect_success 'authors-prog handled special characters in username' '
97 svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
98 (
99 cd x &&
100 git svn --authors-prog=../svn-authors-prog fetch &&
a4d4e32a
PK
101 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
102 grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual &&
d3d7d47e
ML
103 ! test -f evil
104 )
105'
106
36db1edd 107test_done