remote-hg: improve lightweight tag author
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 25 May 2013 02:29:56 +0000 (21:29 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2013 15:02:05 +0000 (08:02 -0700)
Use git's committer.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/remote-helpers/git-remote-hg
index a1b22f7c6c7e6145a8b0df126fbba5283a29f659..fa76b3f610c1c46a9cb2fad7c2f93f6589726a9f 100755 (executable)
@@ -840,13 +840,23 @@ def write_tag(repo, tag, node, msg, author):
 
     p1 = tip.hex()
     p2 = '0' * 40
-    if not author:
-        author = (None, 0, 0)
-    user, date, tz = author
+    if author:
+        user, date, tz = author
+        date_tz = (date, tz)
+    else:
+        cmd = ['git', 'var', 'GIT_COMMITTER_IDENT']
+        process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+        output, _ = process.communicate()
+        m = re.match('^.* <.*>', output)
+        if m:
+            user = m.group(0)
+        else:
+            user = repo.ui.username()
+        date_tz = None
 
     ctx = context.memctx(repo, (p1, p2), msg,
             ['.hgtags'], getfilectx,
-            user, (date, tz), {'branch' : branch})
+            user, date_tz, {'branch' : branch})
 
     tmp = encoding.encoding
     encoding.encoding = 'utf-8'