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:
Russ Cox 2009-11-04 03:15:24 -08:00
parent 56a38f25a7
commit 506ce11f03
1 changed files with 27 additions and 10 deletions

View File

@ -187,8 +187,7 @@ class CL(object):
patches = [x.split(" ", 1) for x in lines[2:]] patches = [x.split(" ", 1) for x in lines[2:]]
ui.status(msg + "\n") ui.status(msg + "\n")
if not response_body.startswith("Issue created.") and not response_body.startswith("Issue updated."): if not response_body.startswith("Issue created.") and not response_body.startswith("Issue updated."):
print response_body raise util.Abort("failed to update issue: " + response_body)
raise "failed to update issue"
issue = msg[msg.rfind("/")+1:] issue = msg[msg.rfind("/")+1:]
self.name = issue self.name = issue
if not self.url: if not self.url:
@ -258,6 +257,12 @@ def ParseCL(text, name):
def SplitCommaSpace(s): def SplitCommaSpace(s):
return s.replace(",", " ").split() return s.replace(",", " ").split()
def CutDomain(s):
i = s.find('@')
if i >= 0:
s = s[0:i]
return s
def JoinComma(l): def JoinComma(l):
return ", ".join(l) return ", ".join(l)
@ -737,12 +742,26 @@ def reposetup(ui, repo):
cmdutil.match = ReplacementForCmdutilMatch cmdutil.match = ReplacementForCmdutilMatch
RietveldSetup(ui, repo) 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): def submit(ui, repo, *pats, **opts):
"""submit change to remote repository """submit change to remote repository
Submits change to remote repository. Submits change to remote repository.
Bails out if the local repository is not in sync with the remote one. Bails out if the local repository is not in sync with the remote one.
""" """
CheckContributor(ui, repo)
repo.ui.quiet = True repo.ui.quiet = True
if not opts["no_incoming"] and Incoming(ui, repo, opts): if not opts["no_incoming"] and Incoming(ui, repo, opts):
return "local repository out of date; must sync before submit" return "local repository out of date; must sync before submit"
@ -753,13 +772,13 @@ def submit(ui, repo, *pats, **opts):
about = "" about = ""
if cl.reviewer: if cl.reviewer:
about += "R=" + JoinComma(cl.reviewer) + "\n" about += "R=" + JoinComma([CutDomain(s) for s in cl.reviewer]) + "\n"
if opts.get('tbr'): if opts.get('tbr'):
tbr = SplitCommaSpace(opts.get('tbr')) tbr = SplitCommaSpace(opts.get('tbr'))
cl.reviewer = Add(cl.reviewer, 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: if cl.cc:
about += "CC=" + JoinComma(cl.cc) + "\n" about += "CC=" + JoinComma([CutDomain(s) for s in cl.cc]) + "\n"
if not cl.reviewer: if not cl.reviewer:
return "no reviewers listed in CL" return "no reviewers listed in CL"
@ -1136,11 +1155,9 @@ def RietveldSetup(ui, repo):
cc = x cc = x
server_url_base = "http://" + server + "/" server_url_base = "http://" + server + "/"
x = ui.config("codereview", "server_url_base")
if x is not None: # TODO(rsc): Remove after release
server_url_base = x server_url_base = "http://go/go-review/"
if not server_url_base.endswith("/"):
server_url_base += "/"
testing = ui.config("codereview", "testing") testing = ui.config("codereview", "testing")
force_google_account = ui.configbool("codereview", "force_google_account", False) force_google_account = ui.configbool("codereview", "force_google_account", False)