gerrit: add support for non-google email addresses
This patch adds support for non-chromium and non-google email addresses
This will be helpful for third-party contributors to find their patches
and use the facilities provided by the "gerrit" command.
The mail address will be fetched from the git configuration. If a domain
in google.com or chromium.org is found, the script will automatically
append the second email address other domain to preserve existing
behavior.
BUG=none
TEST=Unit test
Change-Id: I802d5e887d2ea9532abc848f014d0ee3fd6c813a
Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
Reviewed-on: https://chromium-review.googlesource.com/236721
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index 2b70fba..f1555a1 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -12,7 +12,6 @@
from __future__ import print_function
import inspect
-import os
import pprint
import re
@@ -20,6 +19,7 @@
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import gerrit
+from chromite.lib import git
from chromite.lib import gob_util
from chromite.lib import terminal
@@ -154,9 +154,13 @@
def _MyUserInfo():
- username = os.environ['USER']
- emails = ['%s@%s' % (username, domain)
- for domain in ('google.com', 'chromium.org')]
+ email = git.GetProjectUserEmail(constants.CHROMITE_DIR)
+ [username, _, domain] = email.partition('@')
+ if domain in ('google.com', 'chromium.org'):
+ emails = ['%s@%s' % (username, domain)
+ for domain in ('google.com', 'chromium.org')]
+ else:
+ emails = [email]
reviewers = ['reviewer:%s' % x for x in emails]
owners = ['owner:%s' % x for x in emails]
return emails, reviewers, owners