remote-bzr: set author if available
authorDavid Engster <deng@randomsample.de>
Sat, 6 Apr 2013 03:49:19 +0000 (21:49 -0600)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Apr 2013 07:39:27 +0000 (00:39 -0700)
[fc: added tests]

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/test-bzr.sh
index f818e93f1192d779a8ac8e3694f217f481af98db..a99a92412fe3e837bd732df54785f54562961262 100755 (executable)
@@ -266,7 +266,12 @@ def export_branch(branch, name):
         tz = rev.timezone
         committer = rev.committer.encode('utf-8')
         committer = "%s %u %s" % (fixup_user(committer), time, gittz(tz))
-        author = committer
+        authors = rev.get_apparent_authors()
+        if authors:
+            author = authors[0].encode('utf-8')
+            author = "%s %u %s" % (fixup_user(author), time, gittz(tz))
+        else:
+            author = committer
         msg = rev.message.encode('utf-8')
 
         msg += '\n'
index f0672f618de6aae1f47d73b0b696d84e5177e6cf..1a9c8d775cc7afb232b84af392291708bef33703 100755 (executable)
@@ -164,4 +164,19 @@ test_expect_success 'moving directory' '
   test_cmp expected actual
 '
 
+test_expect_success 'different authors' '
+  (cd bzrrepo &&
+  echo john >> content &&
+  bzr commit -m john \
+    --author "Jane Rey <jrey@example.com>" \
+    --author "John Doe <jdoe@example.com>") &&
+
+  (cd gitrepo &&
+  git pull &&
+  git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual) &&
+
+  echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
+  test_cmp expected actual
+'
+
 test_done