aboutsummaryrefslogtreecommitdiff
path: root/t/t9130-git-svn-authors-file.sh
blob: b8fb277562e7782cf538ba7011214b4cf9136484 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
#
# Copyright (c) 2008 Eric Wong
#

test_description='git svn authors file tests'

. ./lib-git-svn.sh

cat > svn-authors <<EOF
aa = AAAAAAA AAAAAAA <aa@example.com>
bb = BBBBBBB BBBBBBB <bb@example.com>
EOF

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

test_expect_success 'start import with incomplete authors file' '
	! git svn clone --authors-file=svn-authors "$svnrepo" x
	'

test_expect_success 'imported 2 revisions successfully' '
	(
		cd x
		test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 2 &&
		git rev-list -1 --pretty=raw refs/remotes/git-svn | \
		  grep "^author BBBBBBB BBBBBBB <bb@example\.com> " &&
		git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
		  grep "^author AAAAAAA AAAAAAA <aa@example\.com> "
	)
	'

cat >> svn-authors <<EOF
cc = CCCCCCC CCCCCCC <cc@example.com>
dd = DDDDDDD DDDDDDD <dd@example.com>
EOF

test_expect_success 'continues to import once authors have been added' '
	(
		cd x
		git svn fetch --authors-file=../svn-authors &&
		test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 4 &&
		git rev-list -1 --pretty=raw refs/remotes/git-svn | \
		  grep "^author DDDDDDD DDDDDDD <dd@example\.com> " &&
		git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
		  grep "^author CCCCCCC CCCCCCC <cc@example\.com> "
	)
	'

test_expect_success 'authors-file against globs' '
	svn mkdir -m globs --username aa \
	  "$svnrepo"/aa/trunk "$svnrepo"/aa/branches "$svnrepo"/aa/tags &&
	git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work &&
	for i in bb ee cc
	do
		branch="aa/branches/$i"
		svn mkdir -m "$branch" --username $i "$svnrepo/$branch"
	done
	'

test_expect_success 'fetch fails on ee' '
	( cd aa-work && ! git svn fetch --authors-file=../svn-authors )
	'

tmp_config_get () {
	GIT_CONFIG=.git/svn/.metadata git config --get "$1"
}

test_expect_success 'failure happened without negative side effects' '
	(
		cd aa-work &&
		test 6 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" &&
		test 6 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`"
	)
	'

cat >> svn-authors <<EOF
ee = EEEEEEE EEEEEEE <ee@example.com>
EOF

test_expect_success 'fetch continues after authors-file is fixed' '
	(
		cd aa-work &&
		git svn fetch --authors-file=../svn-authors &&
		test 8 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" &&
		test 8 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`"
	)
	'

test_done