]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9138-git-svn-authors-prog.sh
git-svn: allow empty email-address using authors-prog and authors-file
[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 (
41 cd x
27fe43e8 42 test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6
36db1edd 43 )
01730a3b 44'
36db1edd
ML
45
46test_expect_success 'authors-prog ran correctly' '
47 (
48 cd x
49 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
50 grep "^author ee-foo <ee-foo@example\.com> " &&
51 git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \
52 grep "^author dd <dd@sub\.example\.com> " &&
53 git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \
54 grep "^author cc <cc@sub\.example\.com> " &&
55 git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \
56 grep "^author bb <bb@example\.com> " &&
57 git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \
58 grep "^author aa <aa@example\.com> "
59 )
01730a3b 60'
36db1edd
ML
61
62test_expect_success 'authors-file overrode authors-prog' '
63 (
64 cd x
65 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
66 grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> "
67 )
01730a3b 68'
36db1edd 69
d3d7d47e
ML
70git --git-dir=x/.git config --unset svn.authorsfile
71git --git-dir=x/.git config --unset svn.authorsprog
72
cb427e9e
AH
73test_expect_success 'authors-prog imported user without email' '
74 svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
75 (
76 cd x &&
77 git svn fetch --authors-prog=../svn-authors-prog &&
78 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
79 grep "^author gg <> "
80 )
81'
82
83test_expect_success 'imported without authors-prog and authors-file' '
84 svn mkdir -m hh --username hh "$svnrepo"/hh &&
85 (
86 uuid=$(svn info "$svnrepo" |
87 sed -n "s/^Repository UUID: //p") &&
88 cd x &&
89 git svn fetch &&
90 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
91 grep "^author hh <hh@$uuid> "
92 )
93'
94
d3d7d47e
ML
95test_expect_success 'authors-prog handled special characters in username' '
96 svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
97 (
98 cd x &&
99 git svn --authors-prog=../svn-authors-prog fetch &&
100 git rev-list -1 --pretty=raw refs/remotes/git-svn |
101 grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
102 ! test -f evil
103 )
104'
105
36db1edd 106test_done