3 # Copyright (c) 2012 Felipe Contreras
6 test_description='Test remote-bzr'
8 test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
9 . "$TEST_DIRECTORY"/test-lib.sh
11 if ! test_have_prereq PYTHON
13 skip_all='skipping remote-bzr tests; python not available'
17 if ! python -c 'import bzrlib'
19 skip_all='skipping remote-bzr tests; bzr not available'
25 git --git-dir=$1/.git log --format='%s' -1 $2 >actual
26 test_cmp expected actual
29 bzr whoami "A U Thor <author@example.com>"
31 test_expect_success 'cloning' '
40 git clone "bzr::bzrrepo" gitrepo &&
41 check gitrepo HEAD one
44 test_expect_success 'pulling' '
51 (cd gitrepo && git pull) &&
53 check gitrepo HEAD two
56 test_expect_success 'pushing' '
59 echo three >content &&
60 git commit -a -m three &&
64 echo three >expected &&
65 cat bzrrepo/content >actual &&
66 test_cmp expected actual
69 test_expect_success 'roundtrip' '
73 git log --format="%s" -1 origin/master >actual
75 echo three >expected &&
76 test_cmp expected actual &&
78 (cd gitrepo && git push && git pull) &&
86 (cd gitrepo && git pull && git push) &&
88 check gitrepo HEAD four &&
93 git commit -a -m five &&
97 (cd bzrrepo && bzr revert) &&
99 echo five >expected &&
100 cat bzrrepo/content >actual &&
101 test_cmp expected actual
105 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
106 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
107 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
110 test_expect_success 'special modes' '
113 echo exec >executable
114 chmod +x executable &&
116 bzr commit -m exec &&
119 bzr commit -m link &&
128 git ls-tree HEAD >../actual
131 test_cmp expected actual &&
135 git cat-file -p HEAD:link >../actual
138 printf content >expected &&
139 test_cmp expected actual
143 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
144 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
145 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
146 040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
149 test_expect_success 'moving directory' '
153 echo one >movedir/one &&
154 echo two >movedir/two &&
156 bzr commit -m movedir &&
157 bzr mv movedir movedir-new &&
158 bzr commit -m movedir-new
164 git ls-tree HEAD >../actual
167 test_cmp expected actual
170 test_expect_success 'different authors' '
173 echo john >>content &&
175 --author "Jane Rey <jrey@example.com>" \
176 --author "John Doe <jdoe@example.com>"
182 git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
185 echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
186 test_cmp expected actual
189 # cleanup previous stuff
190 rm -rf bzrrepo gitrepo
192 test_expect_success 'fetch utf-8 filenames' '
193 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
206 bzr commit -m add-utf-8 &&
208 bzr commit -m test-utf-8 &&
210 bzr mv "ærø" "ø~?" &&
211 bzr commit -m bzr-mv-utf-8
215 git clone "bzr::bzrrepo" gitrepo &&
217 git -c core.quotepath=false ls-files >../actual
219 echo "ø~?" >expected &&
220 test_cmp expected actual
223 test_expect_success 'push utf-8 filenames' '
224 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
226 mkdir -p tmp && cd tmp &&
235 echo one >>content &&
241 git clone "bzr::bzrrepo" gitrepo &&
246 git commit -m utf-8 &&
251 (cd bzrrepo && bzr ls >../actual) &&
252 printf "content\nærø\n" >expected &&
253 test_cmp expected actual
256 test_expect_success 'pushing a merge' '
257 test_when_finished "rm -rf bzrrepo gitrepo" &&
267 git clone "bzr::bzrrepo" gitrepo &&
277 echo three >content &&
278 git commit -a -m three &&
280 git merge origin/master || true &&
281 echo three >content &&
282 git commit -a --no-edit &&
286 echo three >expected &&
287 cat bzrrepo/content >actual &&
288 test_cmp expected actual
297 test_expect_success 'proper bzr repo' '
298 test_when_finished "rm -rf bzrrepo gitrepo" &&
300 bzr init-repo bzrrepo &&
303 bzr init bzrrepo/trunk &&
305 echo one >>content &&
311 bzr branch bzrrepo/trunk bzrrepo/branch &&
313 echo two >>content &&
318 git clone "bzr::bzrrepo" gitrepo &&
320 git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
323 test_cmp expected actual
326 test_expect_success 'strip' '
327 test_when_finished "rm -rf bzrrepo gitrepo" &&
333 echo one >>content &&
337 echo two >>content &&
341 git clone "bzr::bzrrepo" gitrepo &&
345 bzr uncommit --force &&
347 echo three >>content &&
348 bzr commit -m three &&
350 echo four >>content &&
351 bzr commit -m four &&
352 bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
358 git log --format="%an %ad %s" --date=short origin/master >../actual
361 test_cmp expected actual
364 test_expect_success 'export utf-8 authors' '
365 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
370 GIT_COMMITTER_NAME="Grégoire"
371 export GIT_COMMITTER_NAME
378 echo greg >>content &&
381 git remote add bzr "bzr::../bzrrepo" &&
387 bzr log | grep "^committer: " >../actual
390 echo "committer: Grégoire <committer@example.com>" >expected &&
391 test_cmp expected actual