3 # Copyright (c) 2012 Felipe Contreras
6 test_description='Test remote-bzr'
10 if ! test_have_prereq PYTHON
12 skip_all='skipping remote-bzr tests; python not available'
16 if ! "$PYTHON_PATH" -c 'import bzrlib' > /dev/null 2>&1
18 skip_all='skipping remote-bzr tests; bzr not available'
24 git --git-dir=$1/.git log --format='%s' -1 $2 > actual
25 test_cmp expected actual
28 bzr whoami "A U Thor <author@example.com>"
30 test_expect_success 'cloning' '
39 git clone "bzr::bzrrepo" gitrepo &&
40 check gitrepo HEAD one
43 test_expect_success 'pulling' '
50 (cd gitrepo && git pull) &&
52 check gitrepo HEAD two
55 test_expect_success 'pushing' '
58 echo three > content &&
59 git commit -a -m three &&
63 echo three > expected &&
64 cat bzrrepo/content > actual &&
65 test_cmp expected actual
68 test_expect_success 'forced pushing' '
71 echo three-new > content &&
72 git commit -a --amend -m three-new &&
78 # the forced update overwrites the bzr branch but not the bzr
79 # working directory (it tries to merge instead)
83 echo three-new > expected &&
84 cat bzrrepo/content > actual &&
85 test_cmp expected actual
88 test_expect_success 'roundtrip' '
92 git log --format="%s" -1 origin/master > actual
94 echo three-new > expected &&
95 test_cmp expected actual &&
97 (cd gitrepo && git push && git pull) &&
101 echo four > content &&
105 (cd gitrepo && git pull && git push) &&
107 check gitrepo HEAD four &&
111 echo five > content &&
112 git commit -a -m five &&
116 (cd bzrrepo && bzr revert) &&
118 echo five > expected &&
119 cat bzrrepo/content > actual &&
120 test_cmp expected actual
123 cat > expected <<\EOF
124 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
125 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
126 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
129 test_expect_success 'special modes' '
132 echo exec > executable
133 chmod +x executable &&
135 bzr commit -m exec &&
138 bzr commit -m link &&
147 git ls-tree HEAD > ../actual
150 test_cmp expected actual &&
154 git cat-file -p HEAD:link > ../actual
157 printf content > expected &&
158 test_cmp expected actual
161 cat > expected <<\EOF
162 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
163 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
164 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
165 040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
168 test_expect_success 'moving directory' '
172 echo one > movedir/one &&
173 echo two > movedir/two &&
175 bzr commit -m movedir &&
176 bzr mv movedir movedir-new &&
177 bzr commit -m movedir-new
183 git ls-tree HEAD > ../actual
186 test_cmp expected actual
189 test_expect_success 'different authors' '
192 echo john >> content &&
194 --author "Jane Rey <jrey@example.com>" \
195 --author "John Doe <jdoe@example.com>"
201 git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
204 echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
205 test_cmp expected actual
208 # cleanup previous stuff
209 rm -rf bzrrepo gitrepo
211 test_expect_success 'fetch utf-8 filenames' '
212 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
221 echo test >> "ærø" &&
223 echo test >> "ø~?" &&
225 bzr commit -m add-utf-8 &&
226 echo test >> "ærø" &&
227 bzr commit -m test-utf-8 &&
229 bzr mv "ærø" "ø~?" &&
230 bzr commit -m bzr-mv-utf-8
234 git clone "bzr::bzrrepo" gitrepo &&
236 git -c core.quotepath=false ls-files > ../actual
238 echo "ø~?" > expected &&
239 test_cmp expected actual
242 test_expect_success 'push utf-8 filenames' '
243 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
245 mkdir -p tmp && cd tmp &&
254 echo one >> content &&
260 git clone "bzr::bzrrepo" gitrepo &&
263 echo test >> "ærø" &&
265 git commit -m utf-8 &&
270 (cd bzrrepo && bzr ls > ../actual) &&
271 printf "content\nærø\n" > expected &&
272 test_cmp expected actual
275 test_expect_success 'pushing a merge' '
276 test_when_finished "rm -rf bzrrepo gitrepo" &&
281 echo one > content &&
286 git clone "bzr::bzrrepo" gitrepo &&
290 echo two > content &&
296 echo three > content &&
297 git commit -a -m three &&
299 git merge origin/master || true &&
300 echo three > content &&
301 git commit -a --no-edit &&
305 echo three > expected &&
306 cat bzrrepo/content > actual &&
307 test_cmp expected actual
310 cat > expected <<\EOF
316 test_expect_success 'proper bzr repo' '
317 test_when_finished "rm -rf bzrrepo gitrepo" &&
319 bzr init-repo bzrrepo &&
322 bzr init bzrrepo/trunk &&
324 echo one >> content &&
330 bzr branch bzrrepo/trunk bzrrepo/branch &&
332 echo two >> content &&
337 git clone "bzr::bzrrepo" gitrepo &&
339 git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
342 test_cmp expected actual
345 test_expect_success 'strip' '
346 test_when_finished "rm -rf bzrrepo gitrepo" &&
352 echo one >> content &&
356 echo two >> content &&
360 git clone "bzr::bzrrepo" gitrepo &&
364 bzr uncommit --force &&
366 echo three >> content &&
367 bzr commit -m three &&
369 echo four >> content &&
370 bzr commit -m four &&
371 bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
377 git log --format="%an %ad %s" --date=short origin/master > ../actual
380 test_cmp expected actual
383 test_expect_success 'export utf-8 authors' '
384 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && GIT_COMMITTER_NAME=\"C O Mitter\""
389 GIT_COMMITTER_NAME="Grégoire"
390 export GIT_COMMITTER_NAME
397 echo greg >> content &&
400 git remote add bzr "bzr::../bzrrepo" &&
406 bzr log | grep "^committer: " > ../actual
409 echo "committer: Grégoire <committer@example.com>" > expected &&
410 test_cmp expected actual
413 test_expect_success 'push different author' '
414 test_when_finished "rm -rf bzrrepo gitrepo" &&
421 echo john >> content &&
423 git commit -m john --author "John Doe <jdoe@example.com>" &&
424 git remote add bzr "bzr::../bzrrepo" &&
430 bzr log | grep "^author: " > ../actual
433 echo "author: John Doe <jdoe@example.com>" > expected &&
434 test_cmp expected actual