HEADS-UP: new Git hook linters for whitespace & commit msgs

Hello GHC devs, I finally got to finish reworked Git hook validations[1] which are active effective immediately for the ghc.git repo: - A new whitespace linter that enforces 3 separate in variants for files with the suffixes .hs .hsc .lhs .cabal .c .h .lhs-boot .hs-boot .x .y the 3 invariants (i.e. if the particular invariant held before the commit, it ought to hold afterwards as well): 1. no TABs 2. no trailing whitespaces (NEW) 3. no missing final EOL (NEW) - A new commit msg linter The rationale is explained in http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html TLDR: The structural conventions enforced by the new linter avoid messing up the output of Git tooling; Editors with support for commit-msg syntax-coloring like Vim or Emacs also follow these conventions. This linter has soft (-> warnings) and hard limits (-> error/rejection) The most important hard limits are: - subject line (i.e. 1st line) 80-char max length (& 8-chars min len) - 2nd line must be empty (if it exists) - body lines (i.e. 3rd+ lines) 100-char max length For more details about additional checks see actual code in [1]; the linter tries to give verbose error/warning messages and pointing exactly to the offending lines. Comments/suggestions/debate/pull-requests/etc welcome! PS: the new validators can easily be tested locally on a Git tree (although I've only tested this on Linux): usage: validate-whitespace <git-dir> [<commit-id>+] and you can pass symbolic refs such as 'HEAD' for the <commit-id>, e.g. validate-whitespace ~/Work/ghc-tree/.git HEAD Cheers, hvr [1]: https://github.com/haskell-infra/git-haskell-org-hooks/tree/master/src

Great. Are these invariants documented on the GHC developers wiki? This email will soon be lost, but the wiki lives. Thanks Simon | -----Original Message----- | From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Herbert | Valerio Riedel | Sent: 09 March 2015 08:05 | To: ghc-devs | Subject: HEADS-UP: new Git hook linters for whitespace & commit msgs | | Hello GHC devs, | | I finally got to finish reworked Git hook validations[1] which are | active effective immediately for the ghc.git repo: | | - A new whitespace linter that enforces 3 separate in variants for files | with the suffixes | | .hs .hsc .lhs .cabal .c .h .lhs-boot .hs-boot .x .y | | the 3 invariants (i.e. if the particular invariant held before the | commit, it ought to hold afterwards as well): | | 1. no TABs | 2. no trailing whitespaces (NEW) | 3. no missing final EOL (NEW) | | | - A new commit msg linter | | The rationale is explained in | http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html | | TLDR: The structural conventions enforced by the new linter avoid | messing up the output of Git tooling; Editors with support for | commit-msg syntax-coloring like Vim or Emacs also follow these | conventions. | | This linter has soft (-> warnings) and hard limits (-> | error/rejection) | | The most important hard limits are: | | - subject line (i.e. 1st line) 80-char max length (& 8-chars min len) | - 2nd line must be empty (if it exists) | - body lines (i.e. 3rd+ lines) 100-char max length | | For more details about additional checks see actual code in [1]; the | linter tries to give verbose error/warning messages and pointing | exactly to the offending lines. | | | Comments/suggestions/debate/pull-requests/etc welcome! | | | PS: the new validators can easily be tested locally on a Git tree | (although I've only tested this on Linux): | | usage: validate-whitespace <git-dir> [<commit-id>+] | | and you can pass symbolic refs such as 'HEAD' for the <commit-id>, | e.g. | | validate-whitespace ~/Work/ghc-tree/.git HEAD | | | Cheers, | hvr | | [1]: https://github.com/haskell-infra/git-haskell-org- | hooks/tree/master/src | _______________________________________________ | ghc-devs mailing list | ghc-devs@haskell.org | http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Hello Herbert, I tried to push today and I noticed that there is an unfortunate interaction between Arcanist's commit rewriting and the Signed-off-by hook, which requires the Signed-off-by line to be on a new-line by itself. The problem is Arcanist, by default, rewrites a one line commit message to: This is my first line Summary: Signed-off-by: Edward <...@...> which fails lint. This is pretty annoying; can we relax the lint check or get arc to stop messing this up? Edward Excerpts from Herbert Valerio Riedel's message of 2015-03-09 01:05:12 -0700:
Hello GHC devs,
I finally got to finish reworked Git hook validations[1] which are active effective immediately for the ghc.git repo:
- A new whitespace linter that enforces 3 separate in variants for files with the suffixes
.hs .hsc .lhs .cabal .c .h .lhs-boot .hs-boot .x .y
the 3 invariants (i.e. if the particular invariant held before the commit, it ought to hold afterwards as well):
1. no TABs 2. no trailing whitespaces (NEW) 3. no missing final EOL (NEW)
- A new commit msg linter
The rationale is explained in http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
TLDR: The structural conventions enforced by the new linter avoid messing up the output of Git tooling; Editors with support for commit-msg syntax-coloring like Vim or Emacs also follow these conventions.
This linter has soft (-> warnings) and hard limits (-> error/rejection)
The most important hard limits are:
- subject line (i.e. 1st line) 80-char max length (& 8-chars min len) - 2nd line must be empty (if it exists) - body lines (i.e. 3rd+ lines) 100-char max length
For more details about additional checks see actual code in [1]; the linter tries to give verbose error/warning messages and pointing exactly to the offending lines.
Comments/suggestions/debate/pull-requests/etc welcome!
PS: the new validators can easily be tested locally on a Git tree (although I've only tested this on Linux):
usage: validate-whitespace <git-dir> [<commit-id>+]
and you can pass symbolic refs such as 'HEAD' for the <commit-id>, e.g.
validate-whitespace ~/Work/ghc-tree/.git HEAD
Cheers, hvr
[1]: https://github.com/haskell-infra/git-haskell-org-hooks/tree/master/src

Hi Edward, On 2015-03-09 at 19:58:28 +0100, Edward Z. Yang wrote:
I tried to push today and I noticed that there is an unfortunate interaction between Arcanist's commit rewriting and the Signed-off-by hook, which requires the Signed-off-by line to be on a new-line by itself. The problem is Arcanist, by default, rewrites a one line commit message to:
This is my first line
Summary: Signed-off-by: Edward <...@...>
which fails lint.
This is pretty annoying; can we relax the lint check or get arc to stop messing this up?
I'd *love* to get Arcanist to stop blatantly violating Git's commit msg conventions. For starters, it violates Git's property-trailer syntax convention which requires whitespace-free headings, like 'Reviewed-by:' rather than 'Reviewed By:', c.f. http://git-htmldocs.googlecode.com/git/git-interpret-trailers.html and https://git.wiki.kernel.org/index.php/CommitMessageConventions Otoh, the 'Summary:' "trailer" emitted by Arcanist is completely superfluous and conveys no useful information, but more importantly results in ugly Git commit messages because now the commit msg body always starts with that redundant 'Summary: '-prologue (which then can break the 'Signed-off-by:'-trailer like in your case, causing tooling not to recognize it anymore -- that's why I added that specific lint-check). Cheers, hvr
participants (3)
-
Edward Z. Yang
-
Herbert Valerio Riedel
-
Simon Peyton Jones