remote-bzr: set author if available

[fc: added tests] Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Engster committed Apr 5, 2013 at 21:49 UTC 9d9d698c43aa11d96e9beaf84d77dbceb7460fdd
2 files changed +21 -1
contrib/remote-helpers/git-remote-bzr
+6 -1
@@ -266,7 +266,12 @@ def export_branch(branch, name):
266 tz = rev.timezone
267 committer = rev.committer.encode('utf-8')
268 committer = "%s %u %s" % (fixup_user(committer), time, gittz(tz))
269 - author = committer
269 + authors = rev.get_apparent_authors()
270 + if authors:
271 + author = authors[0].encode('utf-8')
272 + author = "%s %u %s" % (fixup_user(author), time, gittz(tz))
273 + else:
274 + author = committer
275 msg = rev.message.encode('utf-8')
276
277 msg += '\n'
contrib/remote-helpers/test-bzr.sh
+15
@@ -164,4 +164,19 @@ test_expect_success 'moving directory' '
164 test_cmp expected actual
165 '
166
167 +test_expect_success 'different authors' '
168 + (cd bzrrepo &&
169 + echo john >> content &&
170 + bzr commit -m john \
171 + --author "Jane Rey <jrey@example.com>" \
172 + --author "John Doe <jdoe@example.com>") &&
173 +
174 + (cd gitrepo &&
175 + git pull &&
176 + git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual) &&
177 +
178 + echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
179 + test_cmp expected actual
180 +'
181 +
182 test_done