reviewboard: be more strict about detecting metadata lines (bug 1247012); r?dminor draft
authorGregory Szorc <gps@mozilla.com>
Tue, 09 Feb 2016 11:43:47 -0800
changeset 7181 3da7c445ae8b72ccea94cc425d4b2153839e2ced
parent 7180 a6475facc5420f38927c576894e76b65a4eb187f
child 7182 af97cb628912a2110d1e73dc063b7333a3285b19
push id604
push usergszorc@mozilla.com
push dateTue, 09 Feb 2016 19:43:57 +0000
reviewersdminor
bugs1247012
reviewboard: be more strict about detecting metadata lines (bug 1247012); r?dminor MozReview-Commit-ID: AffMSDjLFNe
hgext/reviewboard/hgrb/util.py
hgext/reviewboard/tests/test-commitid.t
--- a/hgext/reviewboard/hgrb/util.py
+++ b/hgext/reviewboard/hgrb/util.py
@@ -140,15 +140,17 @@ def addcommitid(msg, repo=None, fakeidpa
 
     if not lines:
         return msg, False
 
     if any(l.startswith('MozReview-Commit-ID: ') for l in lines):
         return msg, False
 
     # Insert empty line between main commit message and metadata.
-    if not re.match('^[a-zA-Z-]+: ', lines[-1]):
+    # Metadata lines are have-defined keys and values not containing
+    # whitespaces.
+    if not re.match('^[a-zA-Z-]+: \S+$', lines[-1]) or len(lines) == 1:
         lines.append('')
 
     cid = genid(repo=repo, fakeidpath=fakeidpath)
     lines.append('MozReview-Commit-ID: %s' % cid)
 
     return '\n'.join(lines), True
--- a/hgext/reviewboard/tests/test-commitid.t
+++ b/hgext/reviewboard/tests/test-commitid.t
@@ -126,16 +126,18 @@ Graft will preserve commit id.
 
   $ echo metadata > foo
   $ hg commit -l - << EOF
   > topic: foo
   > 
   > foo: bar baz
   > EOF
   $ hg log -G -T '{rev}:{node|short} {desc}\n' -r '::.'
-  @  8:ad9558f7cd71 topic: foo
+  @  8:0d95b59bce48 topic: foo
   |
   |  foo: bar baz
+  |
   |  MozReview-Commit-ID: TA3f84
-  o  7:12881bf6ca0a foo: empty
+  o  7:acd457e707fc foo: empty
+  |
   |  MozReview-Commit-ID: OTOPw0
   o  0:96ee1d7354c4 initial