Patchwork check-commit: reject double-blank lines at the top level

login
register
mail settings
Submitter Martijn Pieters
Date Feb. 4, 2016, 8:15 p.m.
Message ID <45449d6428804e2441ec.1454616959@mjpieters-mbp>
Download mbox | patch
Permalink /patch/12986/
State Accepted
Headers show

Comments

Martijn Pieters - Feb. 4, 2016, 8:15 p.m.
# HG changeset patch
# User Martijn Pieters <mjpieters@fb.com>
# Date 1454616950 0
#      Thu Feb 04 20:15:50 2016 +0000
# Node ID 45449d6428804e2441ecb8ae5727079e62557876
# Parent  b1878a8f4543825e3f4052dc54323c2a0dbc46f1
check-commit: reject double-blank lines at the top level
Augie Fackler - Feb. 5, 2016, 9:11 p.m.
On Thu, Feb 04, 2016 at 08:15:59PM +0000, Martijn Pieters wrote:
> # HG changeset patch
> # User Martijn Pieters <mjpieters@fb.com>
> # Date 1454616950 0
> #      Thu Feb 04 20:15:50 2016 +0000
> # Node ID 45449d6428804e2441ecb8ae5727079e62557876
> # Parent  b1878a8f4543825e3f4052dc54323c2a0dbc46f1
> check-commit: reject double-blank lines at the top level

Sure, queued.

>
> diff --git a/contrib/check-commit b/contrib/check-commit
> --- a/contrib/check-commit
> +++ b/contrib/check-commit
> @@ -37,6 +37,8 @@
>      (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"),
> +    (r'\n\n\n(def|class)', 'Use just one blank line between top-level '
> +     'functions and class definitions'),
>  ]
>
>  word = re.compile('\S')
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Matt Mackall - Feb. 5, 2016, 10:58 p.m.
On Fri, 2016-02-05 at 16:11 -0500, Augie Fackler wrote:
> On Thu, Feb 04, 2016 at 08:15:59PM +0000, Martijn Pieters wrote:
> > # HG changeset patch
> > # User Martijn Pieters <mjpieters@fb.com>
> > # Date 1454616950 0
> > #      Thu Feb 04 20:15:50 2016 +0000
> > # Node ID 45449d6428804e2441ecb8ae5727079e62557876
> > # Parent  b1878a8f4543825e3f4052dc54323c2a0dbc46f1
> > check-commit: reject double-blank lines at the top level
> 
> Sure, queued.
> 
> > 
> > diff --git a/contrib/check-commit b/contrib/check-commit
> > --- a/contrib/check-commit
> > +++ b/contrib/check-commit
> > @@ -37,6 +37,8 @@
> >      (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"),
> > +    (r'\n\n\n(def|class)', 'Use just one blank line between top-level '
> > +     'functions and class definitions'),

Check-commit runs against diffs and should only be looking at metadata and
newly-introduced changes. So when it's looking at the diff part of the diff, it
should probably only be looking at lines starting with "+". I'm going to drop
this version, I've mailed out a suggested replacement.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/contrib/check-commit b/contrib/check-commit
--- a/contrib/check-commit
+++ b/contrib/check-commit
@@ -37,6 +37,8 @@ 
     (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"),
+    (r'\n\n\n(def|class)', 'Use just one blank line between top-level '
+     'functions and class definitions'),
 ]
 
 word = re.compile('\S')