remote-hg: improve lightweight tag author
Use git's committer. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
May 24, 2013 at 21:29 UTC
d462469b4dd724b162a6ef29d0907eb133a5d56e
1 file changed
+14
-4
contrib/remote-helpers/git-remote-hg
+14
-4
@@ -840,13 +840,23 @@ def write_tag(repo, tag, node, msg, author):
840
841
p1 = tip.hex()
842
p2 = '0' * 40
843
- if not author:
844
- author = (None, 0, 0)
845
- user, date, tz = author
843
+ if author:
844
+ user, date, tz = author
845
+ date_tz = (date, tz)
846
+ else:
847
+ cmd = ['git', 'var', 'GIT_COMMITTER_IDENT']
848
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
849
+ output, _ = process.communicate()
850
+ m = re.match('^.* <.*>', output)
851
+ if m:
852
+ user = m.group(0)
853
+ else:
854
+ user = repo.ui.username()
855
+ date_tz = None
856
857
ctx = context.memctx(repo, (p1, p2), msg,
858
['.hgtags'], getfilectx,
849
- user, (date, tz), {'branch' : branch})
859
+ user, date_tz, {'branch' : branch})
860
861
tmp = encoding.encoding
862
encoding.encoding = 'utf-8'