Skip to content

Commit 672ab62

Browse files
committed
lib/codereview: add LGTM= line to commit messages
The R= is populated by Rietveld, so it's basically anyone who replied to the CL. The LGTM= is meant to record who actually signed off on the CL. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/55390043
1 parent 8371b01 commit 672ab62

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

lib/codereview/codereview.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def PendingText(self, quick=False):
277277
s += "\tAuthor: " + cl.copied_from + "\n"
278278
if not quick:
279279
s += "\tReviewer: " + JoinComma(cl.reviewer) + "\n"
280-
for (who, line) in cl.lgtm:
280+
for (who, line, _) in cl.lgtm:
281281
s += "\t\t" + who + ": " + line + "\n"
282282
s += "\tCC: " + JoinComma(cl.cc) + "\n"
283283
s += "\tFiles:\n"
@@ -493,9 +493,15 @@ def CutDomain(s):
493493
return s
494494

495495
def JoinComma(l):
496+
seen = {}
497+
uniq = []
496498
for s in l:
497499
typecheck(s, str)
498-
return ", ".join(l)
500+
if s not in seen:
501+
seen[s] = True
502+
uniq.append(s)
503+
504+
return ", ".join(uniq)
499505

500506
def ExceptionDetail():
501507
s = str(sys.exc_info()[0])
@@ -556,7 +562,7 @@ def LoadCL(ui, repo, name, web=True):
556562
if m.get('approval', False) == True or m.get('disapproval', False) == True:
557563
who = re.sub('@.*', '', m.get('sender', ''))
558564
text = re.sub("\n(.|\n)*", '', m.get('text', ''))
559-
cl.lgtm.append((who, text))
565+
cl.lgtm.append((who, text, m.get('approval', False)))
560566

561567
set_status("loaded CL " + name)
562568
return cl, ''
@@ -1928,12 +1934,21 @@ def submit(ui, repo, *pats, **opts):
19281934
typecheck(userline, str)
19291935

19301936
about = ""
1931-
if cl.reviewer:
1932-
about += "R=" + JoinComma([CutDomain(s) for s in cl.reviewer]) + "\n"
1937+
1938+
if not cl.lgtm and not opts.get('tbr'):
1939+
raise hg_util.Abort("this CL has not been LGTM'ed")
1940+
if cl.lgtm:
1941+
about += "LGTM=" + JoinComma([CutDomain(who) for (who, line, approval) in cl.lgtm if approval]) + "\n"
1942+
reviewer = cl.reviewer
19331943
if opts.get('tbr'):
19341944
tbr = SplitCommaSpace(opts.get('tbr'))
1945+
for name in tbr:
1946+
if name.startswith('golang-'):
1947+
raise hg_util.Abort("--tbr requires a person, not a mailing list")
19351948
cl.reviewer = Add(cl.reviewer, tbr)
19361949
about += "TBR=" + JoinComma([CutDomain(s) for s in tbr]) + "\n"
1950+
if reviewer:
1951+
about += "R=" + JoinComma([CutDomain(s) for s in reviewer]) + "\n"
19371952
if cl.cc:
19381953
about += "CC=" + JoinComma([CutDomain(s) for s in cl.cc]) + "\n"
19391954

0 commit comments

Comments
 (0)