hooks: use commitparser.py to find reviewers in prevent_webidl_changes.py (
bug 1358608) r?gps
MozReview-Commit-ID: 8KWd1CMOG0N
--- a/hghooks/mozhghooks/prevent_webidl_changes.py
+++ b/hghooks/mozhghooks/prevent_webidl_changes.py
@@ -18,16 +18,18 @@
This hook is to prevent changes to files with strict review requirements in pushes
without proper peer review.
"""
import re
from mercurial.node import short
from mercurial import util
+from mozautomation import commitparser
+
backoutMessage = [re.compile(x) for x in [
r'^(back(ing|ed)?\s+out|backout)',
r'^(revert(ed|ing)?)'
]]
def isBackout(message):
for r in backoutMessage:
if r.search(message):
@@ -128,17 +130,17 @@ def hook(ui, repo, hooktype, node, sourc
message = c.description().lower()
email = util.email(c.user()).lower()
# Ignore backouts
if isBackout(message):
continue
def search(authors, peers):
- matches = re.findall('\Ws?r\s*=\s*(\w+(?:,\w+)*)', message)
+ matches = list(commitparser.parse_requal_reviewers(message))
for match in matches:
if any(reviewer in peers for reviewer in match.split(',')):
return True
# We allow peers to commit changes without any review
# requirements assuming that they have looked at the changes
# they're committing.
if any(peer == email for peer in authors):
return True