Patchwork check-commit: make foo_bar naming regexp less greedy

login
register
mail settings
Submitter Gregory Szorc
Date June 1, 2015, 12:42 a.m.
Message ID <4fe8f70d4bd0bc0ea955.1433119334@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/9416/
State Accepted
Headers show

Comments

Gregory Szorc - June 1, 2015, 12:42 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1433119295 25200
#      Sun May 31 17:41:35 2015 -0700
# Node ID 4fe8f70d4bd0bc0ea9555aa251f214d8f27e3cee
# Parent  583b57ce3bf187f0d30db1336288f1671acfc0c2
check-commit: make foo_bar naming regexp less greedy

\s is equivalent to the character class [ \t\n\r\f\v]. Using \s+ in
a regular expression against input with multiple lines may match across
multiple lines.

For the regexp in question, "\+\s+" would match "+\n " and similar
sequences, leading to false positives for functions that were included
in diff context, after a modified hunk.
Pierre-Yves David - June 1, 2015, 6:44 a.m.
On 05/31/2015 05:42 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1433119295 25200
> #      Sun May 31 17:41:35 2015 -0700
> # Node ID 4fe8f70d4bd0bc0ea9555aa251f214d8f27e3cee
> # Parent  583b57ce3bf187f0d30db1336288f1671acfc0c2
> check-commit: make foo_bar naming regexp less greedy

pushed to the clowncopter.

Thanks!

Patch

diff --git a/contrib/check-commit b/contrib/check-commit
--- a/contrib/check-commit
+++ b/contrib/check-commit
@@ -28,9 +28,9 @@  errors = [
     (r"^# .*\n[^\n]*: *[A-Z][a-z]\S+", "don't capitalize summary lines"),
     (r"^# .*\n.*\.\s+$", "don't add trailing period on summary line"),
     (r"^# .*\n.{78,}", "summary line too long (limit is 78)"),
     (r"^\+\n \n", "adds double empty line"),
-    (r"\+\s+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
+    (r"^\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
 ]
 
 node = os.environ.get("HG_NODE")