hgmo: test for mozlink after firstline filter (
bug 1328717); r?wlach
mozlink doesn't work correctly if it only operates on the first line of
a commit message.
So, we add a crude static analysis test that prints warnings for all
occurrences of this bug.
MozReview-Commit-ID: La6Z6sIVivV
--- a/hgext/hgmo/tests/test-mozlink.t
+++ b/hgext/hgmo/tests/test-mozlink.t
@@ -51,8 +51,33 @@
> EOF
$ hg log -r . -T '{desc|mozlink}\n'
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=124562">bug 124562</a> - fix a thing
Fixes <a href="https://github.com/mozilla/foo/issues/32">#32</a> and <a href="https://github.com/mozilla/foo/issues/462">#462</a>
Source-Repo: <a href="https://github.com/mozilla/foo">https://github.com/mozilla/foo</a>
+
+ $ cd ..
+
+The mozlink filter requires context from the full commit message to work properly.
+If the firstline filter runs before it, it lacks this context. This is a quick
+static analysis check that "mozlink" comes before "firstline".
+
+ $ cat >> checktemplate.py << EOF
+ > import os, sys
+ > for path in sys.stdin:
+ > path = path.rstrip()
+ > lines = open(path, 'rb').readlines()
+ > for i, line in enumerate(lines):
+ > if 'mozlink' in line and 'firstline' in line:
+ > if line.index('firstline') < line.index('mozlink'):
+ > relpath = os.path.relpath(path, os.environ['TESTDIR'])
+ > print('%s:%d has firstline before mozlink' % (relpath, i + 1))
+ > EOF
+
+ $ find $TESTDIR/hgtemplates -type f | $PYTHON checktemplate.py
+ hgtemplates/gitweb_mozilla/map:109 has firstline before mozlink
+ hgtemplates/gitweb_mozilla/map:278 has firstline before mozlink
+ hgtemplates/gitweb_mozilla/map:284 has firstline before mozlink
+ hgtemplates/gitweb_mozilla/map:298 has firstline before mozlink
+ hgtemplates/gitweb_mozilla/changeset.tmpl:32 has firstline before mozlink