include author email in From (#245)

This commit is contained in:
Frédéric Péters 2017-04-25 20:03:38 +02:00
parent 7fc63be7c3
commit 2917c7c674
1 changed files with 7 additions and 0 deletions

View File

@ -113,6 +113,13 @@ class RefChange(object):
raise NotImplementedError()
def generate_header(self, out, subject, include_revs=True, oldrev=None, newrev=None, cc=None):
if include_revs and oldrev and newrev:
authors = [x for x in git.show(newrev).splitlines() if x.startswith('Author:')]
if authors:
author = authors[0]
emails = re.findall(r'[A-Za-z0-9\.-]+@[A-Za-z0-9\.-]+', author)
user_fullname = 'git+' + emails[0]
user = os.environ['USER']
if user_fullname:
from_address = "%s <%s@entrouvert.com>" % (user_fullname, user)