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 -c 'import bzrlib'
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 'roundtrip' '
72 git log --format="%s" -1 origin/master >actual
74 echo three >expected &&
75 test_cmp expected actual &&
77 (cd gitrepo && git push && git pull) &&
85 (cd gitrepo && git pull && git push) &&
87 check gitrepo HEAD four &&
92 git commit -a -m five &&
96 (cd bzrrepo && bzr revert) &&
98 echo five >expected &&
99 cat bzrrepo/content >actual &&
100 test_cmp expected actual
104 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
105 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
106 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
109 test_expect_success 'special modes' '
112 echo exec >executable
113 chmod +x executable &&
115 bzr commit -m exec &&
118 bzr commit -m link &&
127 git ls-tree HEAD >../actual
130 test_cmp expected actual &&
134 git cat-file -p HEAD:link >../actual
137 printf content >expected &&
138 test_cmp expected actual
142 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
143 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
144 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
145 040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
148 test_expect_success 'moving directory' '
152 echo one >movedir/one &&
153 echo two >movedir/two &&
155 bzr commit -m movedir &&
156 bzr mv movedir movedir-new &&
157 bzr commit -m movedir-new
163 git ls-tree HEAD >../actual
166 test_cmp expected actual
169 test_expect_success 'different authors' '
172 echo john >>content &&
174 --author "Jane Rey <jrey@example.com>" \
175 --author "John Doe <jdoe@example.com>"
181 git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
184 echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
185 test_cmp expected actual
188 # cleanup previous stuff
189 rm -rf bzrrepo gitrepo
191 test_expect_success 'fetch utf-8 filenames' '
192 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
205 bzr commit -m add-utf-8 &&
207 bzr commit -m test-utf-8 &&
209 bzr mv "ærø" "ø~?" &&
210 bzr commit -m bzr-mv-utf-8
214 git clone "bzr::bzrrepo" gitrepo &&
216 git -c core.quotepath=false ls-files >../actual
218 echo "ø~?" >expected &&
219 test_cmp expected actual
222 test_expect_success 'push utf-8 filenames' '
223 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
225 mkdir -p tmp && cd tmp &&
234 echo one >>content &&
240 git clone "bzr::bzrrepo" gitrepo &&
245 git commit -m utf-8 &&
250 (cd bzrrepo && bzr ls >../actual) &&
251 printf "content\nærø\n" >expected &&
252 test_cmp expected actual
255 test_expect_success 'pushing a merge' '
256 test_when_finished "rm -rf bzrrepo gitrepo" &&
266 git clone "bzr::bzrrepo" gitrepo &&
276 echo three >content &&
277 git commit -a -m three &&
279 git merge origin/master || true &&
280 echo three >content &&
281 git commit -a --no-edit &&
285 echo three >expected &&
286 cat bzrrepo/content >actual &&
287 test_cmp expected actual
296 test_expect_success 'proper bzr repo' '
297 test_when_finished "rm -rf bzrrepo gitrepo" &&
299 bzr init-repo bzrrepo &&
302 bzr init bzrrepo/trunk &&
304 echo one >>content &&
310 bzr branch bzrrepo/trunk bzrrepo/branch &&
312 echo two >>content &&
317 git clone "bzr::bzrrepo" gitrepo &&
319 git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
322 test_cmp expected actual
325 test_expect_success 'strip' '
326 test_when_finished "rm -rf bzrrepo gitrepo" &&
332 echo one >>content &&
336 echo two >>content &&
340 git clone "bzr::bzrrepo" gitrepo &&
344 bzr uncommit --force &&
346 echo three >>content &&
347 bzr commit -m three &&
349 echo four >>content &&
350 bzr commit -m four &&
351 bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
357 git log --format="%an %ad %s" --date=short origin/master >../actual
360 test_cmp expected actual
363 test_expect_success 'export utf-8 authors' '
364 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
369 GIT_COMMITTER_NAME="Grégoire"
370 export GIT_COMMITTER_NAME
377 echo greg >>content &&
380 git remote add bzr "bzr::../bzrrepo" &&
386 bzr log | grep "^committer: " >../actual
389 echo "committer: Grégoire <committer@example.com>" >expected &&
390 test_cmp expected actual