mirror of
https://github.com/golang/go
synced 2024-11-21 15:34:45 -07:00
codereview: allow multiple email addresses in CONTRIBUTORS
R=r CC=golang-dev https://golang.org/cl/1650041
This commit is contained in:
parent
ae33032893
commit
93f614ff86
@ -101,6 +101,7 @@ if __name__ == "__main__":
|
|||||||
server = "codereview.appspot.com"
|
server = "codereview.appspot.com"
|
||||||
server_url_base = None
|
server_url_base = None
|
||||||
defaultcc = None
|
defaultcc = None
|
||||||
|
contributors = {}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Change list parsing.
|
# Change list parsing.
|
||||||
@ -1021,22 +1022,17 @@ def CheckContributor(ui, repo, user=None):
|
|||||||
return userline
|
return userline
|
||||||
|
|
||||||
def FindContributor(ui, repo, user, warn=True):
|
def FindContributor(ui, repo, user, warn=True):
|
||||||
try:
|
m = re.match(r".*<(.*)>", user)
|
||||||
f = open(repo.root + '/CONTRIBUTORS', 'r')
|
if m:
|
||||||
except:
|
user = m.group(1).lower()
|
||||||
raise util.Abort("cannot open %s: %s" % (repo.root+'/CONTRIBUTORS', ExceptionDetail()))
|
|
||||||
for line in f.readlines():
|
if user not in contributors:
|
||||||
line = line.rstrip()
|
if warn:
|
||||||
if line.startswith('#'):
|
ui.warn("warning: cannot find %s in CONTRIBUTORS\n" % (user,))
|
||||||
continue
|
return None, None
|
||||||
match = re.match(r"(.*) <(.*)>", line)
|
|
||||||
if not match:
|
user, email = contributors[user]
|
||||||
continue
|
return email, "%s <%s>" % (user, email)
|
||||||
if line == user or match.group(2).lower() == user.lower():
|
|
||||||
return match.group(2), line
|
|
||||||
if warn:
|
|
||||||
ui.warn("warning: cannot find %s in CONTRIBUTORS\n" % (user,))
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
def submit(ui, repo, *pats, **opts):
|
def submit(ui, repo, *pats, **opts):
|
||||||
"""submit change to remote repository
|
"""submit change to remote repository
|
||||||
@ -1615,7 +1611,7 @@ class opt(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def RietveldSetup(ui, repo):
|
def RietveldSetup(ui, repo):
|
||||||
global defaultcc, upload_options, rpc, server, server_url_base, force_google_account, verbosity
|
global defaultcc, upload_options, rpc, server, server_url_base, force_google_account, verbosity, contributors
|
||||||
|
|
||||||
# Read repository-specific options from lib/codereview/codereview.cfg
|
# Read repository-specific options from lib/codereview/codereview.cfg
|
||||||
try:
|
try:
|
||||||
@ -1626,6 +1622,26 @@ def RietveldSetup(ui, repo):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = open(repo.root + '/CONTRIBUTORS', 'r')
|
||||||
|
except:
|
||||||
|
raise util.Abort("cannot open %s: %s" % (repo.root+'/CONTRIBUTORS', ExceptionDetail()))
|
||||||
|
for line in f:
|
||||||
|
# CONTRIBUTORS is a list of lines like:
|
||||||
|
# Person <email>
|
||||||
|
# Person <email> <alt-email>
|
||||||
|
# The first email address is the one used in commit logs.
|
||||||
|
if line.startswith('#'):
|
||||||
|
continue
|
||||||
|
m = re.match(r"([^<>]+\S)\s+(<[^<>\s]+>)((\s+<[^<>\s]+>)*)\s*$", line)
|
||||||
|
if m:
|
||||||
|
name = m.group(1)
|
||||||
|
email = m.group(2)[1:-1]
|
||||||
|
contributors[email.lower()] = (name, email)
|
||||||
|
for extra in m.group(3).split():
|
||||||
|
contributors[extra[1:-1].lower()] = (name, email)
|
||||||
|
|
||||||
|
|
||||||
# TODO(rsc): If the repository config has no codereview section,
|
# TODO(rsc): If the repository config has no codereview section,
|
||||||
# do not enable the extension. This allows users to
|
# do not enable the extension. This allows users to
|
||||||
# put the extension in their global .hgrc but only
|
# put the extension in their global .hgrc but only
|
||||||
|
Loading…
Reference in New Issue
Block a user