Bug 1649565: Sentry setup should support user-less VCS setups r=rstewart

Differential Revision: https://phabricator.services.mozilla.com/D81792
This commit is contained in:
Mitchell Hentges 2020-07-02 18:31:05 +00:00
parent 4660b92c2b
commit 87092a1009

View File

@ -165,7 +165,10 @@ class Repository(object):
@abc.abstractmethod
def get_user_email(self):
"""Return the user's email address."""
"""Return the user's email address.
If no email is configured, then None is returned.
"""
@abc.abstractmethod
def get_upstream(self):
@ -357,7 +360,10 @@ class HgRepository(Repository):
def get_user_email(self):
# Output is in the form "First Last <flast@mozilla.com>"
username = self._run('config', 'ui.username')
username = self._run('config', 'ui.username', return_codes=[0, 1])
if not username:
# No username is set
return None
match = re.search(r'<(.*)>', username)
return match.group(1)
@ -491,7 +497,10 @@ class GitRepository(Repository):
return False
def get_user_email(self):
return self._run('config', 'user.email')
email = self._run('config', 'user.email', return_codes=[0, 1])
if not email:
return None
return email.strip()
def get_upstream(self):
ref = self._run('symbolic-ref', '-q', 'HEAD').strip()