hghooks: reject commit messages that end in 'r?' (
bug 1319738) r?gps
MozReview-Commit-ID: 6NhAQaKJHaT
--- a/hghooks/mozhghooks/commit-message.py
+++ b/hghooks/mozhghooks/commit-message.py
@@ -13,17 +13,17 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import re
from mercurial.node import hex
-INVALID_REVIEW_FLAG_RE = re.compile(r'[\s\.;]r\?\w')
+INVALID_REVIEW_FLAG_RE = re.compile(r'[\s\.;]r\?(?:\w|$)')
goodMessage = [re.compile(x, re.I) for x in [
r'bug [0-9]+',
r'no bug',
r'^(back(ing|ed)?\s+out|backout).*(\s+|\:)[0-9a-f]{12}',
r'^(revert(ed|ing)?).*(\s+|\:)[0-9a-f]{12}',
r'^add(ed|ing)? tag'
--- a/hghooks/tests/test-commit-messages.t
+++ b/hghooks/tests/test-commit-messages.t
@@ -455,16 +455,40 @@ Test some bad commit messages
Bug 100 - Foo. r?bar
*************************************************************
transaction abort!
rollback completed
abort: pretxnchangegroup.commit_message hook failed
[255]
+ $ hg strip -r . > /dev/null
+
+ $ echo review > foo
+ $ hg commit -m "Bug 100 - Foo. r?"
+ $ hg push
+ pushing to $TESTTMP/server
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+
+
+ ************************** ERROR ****************************
+ Rev e56ddd0ce39a contains 'r?' in the commit message. Please use 'r=' instead.
+ test
+ Bug 100 - Foo. r?
+ *************************************************************
+
+
+ transaction abort!
+ rollback completed
+ abort: pretxnchangegroup.commit_message hook failed
+ [255]
IGNORE BAD COMMIT MESSAGES should work
$ echo ignore > foo
$ hg commit -m 'IGNORE BAD COMMIT MESSAGES'
$ hg push
pushing to $TESTTMP/server
searching for changes