mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
various tweaks to code review.
main one is to check at submit time that user name being used in checkin message is listed in the CONTRIBUTORS file. this should catch misconfigurations. another is to cut the @domain part from the R= and CC= lines on checkin messages, so that cc'ing someone on a change does not mean their email address is recorded for all time. R=r CC=go-dev http://go/go-review/1016036
This commit is contained in:
parent
56a38f25a7
commit
506ce11f03
@ -187,8 +187,7 @@ class CL(object):
|
||||
patches = [x.split(" ", 1) for x in lines[2:]]
|
||||
ui.status(msg + "\n")
|
||||
if not response_body.startswith("Issue created.") and not response_body.startswith("Issue updated."):
|
||||
print response_body
|
||||
raise "failed to update issue"
|
||||
raise util.Abort("failed to update issue: " + response_body)
|
||||
issue = msg[msg.rfind("/")+1:]
|
||||
self.name = issue
|
||||
if not self.url:
|
||||
@ -258,6 +257,12 @@ def ParseCL(text, name):
|
||||
def SplitCommaSpace(s):
|
||||
return s.replace(",", " ").split()
|
||||
|
||||
def CutDomain(s):
|
||||
i = s.find('@')
|
||||
if i >= 0:
|
||||
s = s[0:i]
|
||||
return s
|
||||
|
||||
def JoinComma(l):
|
||||
return ", ".join(l)
|
||||
|
||||
@ -737,12 +742,26 @@ def reposetup(ui, repo):
|
||||
cmdutil.match = ReplacementForCmdutilMatch
|
||||
RietveldSetup(ui, repo)
|
||||
|
||||
def CheckContributor(ui, repo):
|
||||
user = ui.config("ui", "username")
|
||||
if not user:
|
||||
raise util.Abort("[ui] username is not configured in .hgrc")
|
||||
try:
|
||||
f = open(repo.root + '/CONTRIBUTORS', 'r')
|
||||
except:
|
||||
raise util.Abort("cannot open %s: %s" % (repo.root+'/CONTRIBUTORS', ExceptionDetail()))
|
||||
for line in f.readlines():
|
||||
if line.rstrip() == user.rstrip():
|
||||
return
|
||||
raise util.Abort("cannot find %s in CONTRIBUTORS" % (user,))
|
||||
|
||||
def submit(ui, repo, *pats, **opts):
|
||||
"""submit change to remote repository
|
||||
|
||||
Submits change to remote repository.
|
||||
Bails out if the local repository is not in sync with the remote one.
|
||||
"""
|
||||
CheckContributor(ui, repo)
|
||||
repo.ui.quiet = True
|
||||
if not opts["no_incoming"] and Incoming(ui, repo, opts):
|
||||
return "local repository out of date; must sync before submit"
|
||||
@ -753,13 +772,13 @@ def submit(ui, repo, *pats, **opts):
|
||||
|
||||
about = ""
|
||||
if cl.reviewer:
|
||||
about += "R=" + JoinComma(cl.reviewer) + "\n"
|
||||
about += "R=" + JoinComma([CutDomain(s) for s in cl.reviewer]) + "\n"
|
||||
if opts.get('tbr'):
|
||||
tbr = SplitCommaSpace(opts.get('tbr'))
|
||||
cl.reviewer = Add(cl.reviewer, tbr)
|
||||
about += "TBR=" + JoinComma(tbr) + "\n"
|
||||
about += "TBR=" + JoinComma([CutDomain(s) for s in tbr]) + "\n"
|
||||
if cl.cc:
|
||||
about += "CC=" + JoinComma(cl.cc) + "\n"
|
||||
about += "CC=" + JoinComma([CutDomain(s) for s in cl.cc]) + "\n"
|
||||
|
||||
if not cl.reviewer:
|
||||
return "no reviewers listed in CL"
|
||||
@ -1136,11 +1155,9 @@ def RietveldSetup(ui, repo):
|
||||
cc = x
|
||||
|
||||
server_url_base = "http://" + server + "/"
|
||||
x = ui.config("codereview", "server_url_base")
|
||||
if x is not None:
|
||||
server_url_base = x
|
||||
if not server_url_base.endswith("/"):
|
||||
server_url_base += "/"
|
||||
|
||||
# TODO(rsc): Remove after release
|
||||
server_url_base = "http://go/go-review/"
|
||||
|
||||
testing = ui.config("codereview", "testing")
|
||||
force_google_account = ui.configbool("codereview", "force_google_account", False)
|
||||
|
Loading…
Reference in New Issue
Block a user