reviewboard: be more strict about detecting metadata lines (
bug 1247012); r?dminor
MozReview-Commit-ID: AffMSDjLFNe
--- 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