2009-05-15 03:27:15 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Eric Wong, Mark Lodato
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='git svn authors prog tests'
|
|
|
|
|
|
|
|
. ./lib-git-svn.sh
|
|
|
|
|
2014-05-25 21:24:54 +02:00
|
|
|
write_script svn-authors-prog "$PERL_PATH" <<-\EOF
|
|
|
|
$_ = shift;
|
2018-03-24 11:20:46 +01:00
|
|
|
if (s/-hermit//) {
|
|
|
|
print "$_ <>\n";
|
|
|
|
} elsif (s/-sub$//) {
|
2014-05-25 21:24:54 +02:00
|
|
|
print "$_ <$_\@sub.example.com>\n";
|
|
|
|
} else {
|
|
|
|
print "$_ <$_\@example.com>\n";
|
|
|
|
}
|
2009-05-15 03:27:15 +02:00
|
|
|
EOF
|
|
|
|
|
2014-05-25 21:24:54 +02:00
|
|
|
test_expect_success 'svn-authors setup' '
|
|
|
|
cat >svn-authors <<-\EOF
|
|
|
|
ff = FFFFFFF FFFFFFF <fFf@other.example.com>
|
|
|
|
EOF
|
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
|
|
|
test_expect_success 'setup svnrepo' '
|
|
|
|
for i in aa bb cc-sub dd-sub ee-foo ff
|
|
|
|
do
|
2021-12-09 06:11:15 +01:00
|
|
|
svn mkdir -m $i --username $i "$svnrepo"/$i || return 1
|
2009-05-15 03:27:15 +02:00
|
|
|
done
|
2014-05-25 21:24:54 +02:00
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
|
|
|
test_expect_success 'import authors with prog and file' '
|
|
|
|
git svn clone --authors-prog=./svn-authors-prog \
|
|
|
|
--authors-file=svn-authors "$svnrepo" x
|
2014-05-25 21:24:54 +02:00
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
|
|
|
test_expect_success 'imported 6 revisions successfully' '
|
|
|
|
(
|
2018-07-02 02:24:04 +02:00
|
|
|
cd x &&
|
2018-03-27 19:31:37 +02:00
|
|
|
git rev-list refs/remotes/git-svn >actual &&
|
|
|
|
test_line_count = 6 actual
|
2009-05-15 03:27:15 +02:00
|
|
|
)
|
2014-05-25 21:24:54 +02:00
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
|
|
|
test_expect_success 'authors-prog ran correctly' '
|
|
|
|
(
|
2018-07-02 02:24:04 +02:00
|
|
|
cd x &&
|
2018-03-27 19:31:37 +02:00
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
|
|
|
|
grep "^author ee-foo <ee-foo@example\.com> " actual &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual &&
|
|
|
|
grep "^author dd <dd@sub\.example\.com> " actual &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual &&
|
|
|
|
grep "^author cc <cc@sub\.example\.com> " actual &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual &&
|
|
|
|
grep "^author bb <bb@example\.com> " actual &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual &&
|
|
|
|
grep "^author aa <aa@example\.com> " actual
|
2009-05-15 03:27:15 +02:00
|
|
|
)
|
2014-05-25 21:24:54 +02:00
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
|
|
|
test_expect_success 'authors-file overrode authors-prog' '
|
|
|
|
(
|
2018-07-02 02:24:04 +02:00
|
|
|
cd x &&
|
2018-03-27 19:31:37 +02:00
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
|
|
|
|
grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual
|
2009-05-15 03:27:15 +02:00
|
|
|
)
|
2014-05-25 21:24:54 +02:00
|
|
|
'
|
2009-05-15 03:27:15 +02:00
|
|
|
|
2009-09-13 02:33:23 +02:00
|
|
|
git --git-dir=x/.git config --unset svn.authorsfile
|
|
|
|
git --git-dir=x/.git config --unset svn.authorsprog
|
|
|
|
|
2018-03-24 11:20:46 +01:00
|
|
|
test_expect_success 'authors-prog imported user without email' '
|
|
|
|
svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
|
|
|
|
(
|
|
|
|
cd x &&
|
|
|
|
git svn fetch --authors-prog=../svn-authors-prog &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn | \
|
|
|
|
grep "^author gg <> "
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'imported without authors-prog and authors-file' '
|
|
|
|
svn mkdir -m hh --username hh "$svnrepo"/hh &&
|
|
|
|
(
|
|
|
|
uuid=$(svn info "$svnrepo" |
|
|
|
|
sed -n "s/^Repository UUID: //p") &&
|
|
|
|
cd x &&
|
|
|
|
git svn fetch &&
|
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn | \
|
|
|
|
grep "^author hh <hh@$uuid> "
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-09-13 02:33:23 +02:00
|
|
|
test_expect_success 'authors-prog handled special characters in username' '
|
|
|
|
svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
|
|
|
|
(
|
|
|
|
cd x &&
|
|
|
|
git svn --authors-prog=../svn-authors-prog fetch &&
|
2018-03-27 19:31:37 +02:00
|
|
|
git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
|
|
|
|
grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual &&
|
2009-09-13 02:33:23 +02:00
|
|
|
! test -f evil
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-05-15 03:27:15 +02:00
|
|
|
test_done
|