Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 84 lines (71 sloc) 2.076 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#!/bin/sh
#
# Copyright (c) 2009 Eric Wong, Mark Lodato
#

test_description='git svn authors prog tests'

. ./lib-git-svn.sh

cat > svn-authors-prog <<'EOF'
#!/usr/bin/perl
$_ = shift;
if (s/-sub$//) {
print "$_ <$_\@sub.example.com>\n";
}
else {
print "$_ <$_\@example.com>\n";
}
EOF
chmod +x svn-authors-prog

cat > svn-authors <<'EOF'
ff = FFFFFFF FFFFFFF <fFf@other.example.com>
EOF

test_expect_success 'setup svnrepo' '
for i in aa bb cc-sub dd-sub ee-foo ff
do
svn mkdir -m $i --username $i "$svnrepo"/$i
done
'

test_expect_success 'import authors with prog and file' '
git svn clone --authors-prog=./svn-authors-prog \
--authors-file=svn-authors "$svnrepo" x
'

test_expect_success 'imported 6 revisions successfully' '
(
cd x
test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 6
)
'

test_expect_success 'authors-prog ran correctly' '
(
cd x
git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
grep "^author ee-foo <ee-foo@example\.com> " &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \
grep "^author dd <dd@sub\.example\.com> " &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \
grep "^author cc <cc@sub\.example\.com> " &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \
grep "^author bb <bb@example\.com> " &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \
grep "^author aa <aa@example\.com> "
)
'

test_expect_success 'authors-file overrode authors-prog' '
(
cd x
git rev-list -1 --pretty=raw refs/remotes/git-svn | \
grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> "
)
'

git --git-dir=x/.git config --unset svn.authorsfile
git --git-dir=x/.git config --unset svn.authorsprog

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 &&
git rev-list -1 --pretty=raw refs/remotes/git-svn |
grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
! test -f evil
)
'

test_done
Something went wrong with that request. Please try again.