Skip to content

llorllale/go-gitlint

Repository files navigation

Release Build Status codecov Go Report Card codebeat GolangCI Powered By: GoReleaser Go Doc PDD status License

go-gitlint

Lint your git!

Usage

$ ./gitlint --help
usage: gitlint [<flags>]

Flags:
  --help                         Show context-sensitive help (also try --help-long and --help-man).
  --subject-regex=SUBJECT-REGEX  Filters commit subjects based on a regular expression.
  --subject-len=SUBJECT-LEN      Filters commit subjects based on length.
  --body-regex=BODY-REGEX        Filters commit message bodies based on a regular expression.
  --path="."                     Path to the git repo ("." by default).
  --since="1970-01-01"           A date in "yyyy-MM-dd" format starting from which commits will be analyzed (default: "1970-01-01")

Additionally, it will look for configurations in a file .gitlint in the current directory if it exists. This file's format is just the same command line flags but each on a separate line. Flags passed through the command line take precedence.

Integrate to your CI

Use the download-gitlint.sh script:

curl -sfL https://raw.githubusercontent.com/llorllale/go-gitlint/master/download-gitlint.sh | sh -s 1.0.0

Specifying the version is optional; if you just want the latest, omit the -s <version> part.

In both cases the correct version for your platform will be downloaded and installed at $GOPATH/bin.

Motivation

  • Validate format of commit message subject and body
  • Lint commit msgs on varios development platforms (Windows, Linux, Mac)
  • Configuration from file with cli args taking precedence
  • commit-msg hook to validate my commit's msg
  • Performance (because a slow pre-commit hook would render the git workflow unmanageable)
  • My first Go project :)

Contributing

Fork this repo, make sure make checks works, and then open a PR.

Build dependencies

To run make checks you will need:

  • Go 1.11.x
  • Ruby 2.x (for pdd)
  • pdd (a ruby gem - gem install pdd)
  • golangci-lint v1.14.0 (expected to be in the ./bin folder)
  • weasel (go get github.com/comcast/weasel)

About

Go lint your commit messages!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •