diff contrib/check-commit @ 43659:99e231afc29c

black: blacken scripts test-check-format.t doesn't appear to detect Python scripts with shebangs. But my editor which is configured to auto run black on Python files does and it appears some files are not blackened. This commit blackens scripts that need it. # skip-blame reformatting Differential Revision: https://phab.mercurial-scm.org/D7420
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 14 Nov 2019 20:35:11 -0800
parents 24a07347aa60
children c102b704edb5
line wrap: on
line diff
--- a/contrib/check-commit	Tue Nov 12 10:17:59 2019 -0500
+++ b/contrib/check-commit	Thu Nov 14 20:35:11 2019 -0800
@@ -27,32 +27,42 @@
 
 errors = [
     (beforepatch + r".*[(]bc[)]", "(BC) needs to be uppercase"),
-    (beforepatch + r".*[(]issue \d\d\d",
-     "no space allowed between issue and number"),
+    (
+        beforepatch + r".*[(]issue \d\d\d",
+        "no space allowed between issue and number",
+    ),
     (beforepatch + r".*[(]bug(\d|\s)", "use (issueDDDD) instead of bug"),
     (commitheader + r"# User [^@\n]+\n", "username is not an email address"),
-    (commitheader + r"(?!merge with )[^#]\S+[^:] ",
-     "summary line doesn't start with 'topic: '"),
+    (
+        commitheader + r"(?!merge with )[^#]\S+[^:] ",
+        "summary line doesn't start with 'topic: '",
+    ),
     (afterheader + r"[A-Z][a-z]\S+", "don't capitalize summary lines"),
     (afterheader + r"^\S+: *[A-Z][a-z]\S+", "don't capitalize summary lines"),
-    (afterheader + r"\S*[^A-Za-z0-9-_]\S*: ",
-     "summary keyword should be most user-relevant one-word command or topic"),
+    (
+        afterheader + r"\S*[^A-Za-z0-9-_]\S*: ",
+        "summary keyword should be most user-relevant one-word command or topic",
+    ),
     (afterheader + r".*\.\s*\n", "don't add trailing period on summary line"),
     (afterheader + r".{79,}", "summary line too long (limit is 78)"),
 ]
 
 word = re.compile(r'\S')
+
+
 def nonempty(first, second):
     if word.search(first):
         return first
     return second
 
+
 def checkcommit(commit, node=None):
     exitcode = 0
     printed = node is None
     hits = []
-    signtag = (afterheader +
-          r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}')
+    signtag = (
+        afterheader + r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}'
+    )
     if re.search(signtag, commit):
         return 0
     for exp, msg in errors:
@@ -84,9 +94,11 @@
 
     return exitcode
 
+
 def readcommit(node):
     return os.popen("hg export %s" % node).read()
 
+
 if __name__ == "__main__":
     exitcode = 0
     node = os.environ.get("HG_NODE")