Patchwork [2,of,2] check-commit: check for double-addition of blank lines

login
register
mail settings
Submitter Matt Mackall
Date Feb. 5, 2016, 10:57 p.m.
Message ID <1b02970df1ded50af05d.1454713038@ruin.waste.org>
Download mbox | patch
Permalink /patch/13024/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Matt Mackall - Feb. 5, 2016, 10:57 p.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1454712841 21600
#      Fri Feb 05 16:54:01 2016 -0600
# Node ID 1b02970df1ded50af05d5e26532325949d8694e5
# Parent  d930d42d30dcbbb26fe82f685eddbb7857d69f31
check-commit: check for double-addition of blank lines

Previously, we were only checking for a blank line being added next to
an existing one. Now we also check for two being added at the same time.
Yuya Nishihara - Feb. 6, 2016, 10:50 a.m.
On Fri, 05 Feb 2016 16:57:18 -0600, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1454712841 21600
> #      Fri Feb 05 16:54:01 2016 -0600
> # Node ID 1b02970df1ded50af05d5e26532325949d8694e5
> # Parent  d930d42d30dcbbb26fe82f685eddbb7857d69f31
> check-commit: check for double-addition of blank lines

LGTM. Pushed this version to clowncopter and dropped old one, thanks.

Patch

diff -r d930d42d30dc -r 1b02970df1de contrib/check-commit
--- a/contrib/check-commit	Fri Feb 05 16:52:02 2016 -0600
+++ b/contrib/check-commit	Fri Feb 05 16:54:01 2016 -0600
@@ -34,7 +34,7 @@ 
      "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)"),
-    (r"\n\+\n \n", "adds double empty line"),
+    (r"\n\+\n( |\+)\n", "adds double empty line"),
     (r"\n \n\+\n", "adds double empty line"),
     (r"\n\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
 ]
diff -r d930d42d30dc -r 1b02970df1de tests/test-contrib-check-commit.t
--- a/tests/test-contrib-check-commit.t	Fri Feb 05 16:52:02 2016 -0600
+++ b/tests/test-contrib-check-commit.t	Fri Feb 05 16:54:01 2016 -0600
@@ -87,6 +87,10 @@ 
   > @@ -599,7 +599,7 @@
   >          if opts.get('all'):
   >  
+  > 
+  > +
+  > + some = otherjunk
+  > +
   > +
   > + def blah_blah(x):
   > +     pass
@@ -102,10 +106,10 @@ 
    This has no topic and ends with a period.
   7: don't add trailing period on summary line
    This has no topic and ends with a period.
-  15: adds double empty line
-   +
-  16: adds a function with foo_bar naming
-   + def blah_blah(x):
   19: adds double empty line
    +
+  20: adds a function with foo_bar naming
+   + def blah_blah(x):
+  23: adds double empty line
+   +
   [1]