command module
Version: v2.1.2+incompatible Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2018 License: Apache-2.0 Imports: 1 Imported by: 0


Gommit CircleCI codecov codebeat badge Go Report Card GoDoc GitHub tag

Gommit analyze commits messages to ensure they follow defined pattern.




Download from release page according to your architecture gommit binary : https://github.com/antham/gommit/releases

Define a file .gommit.toml

Create a file .gommit.toml at the root of your project, for instance :


all="(?:ref|feat|test|fix|style)\\(.*?\\) : .*?\n(?:\n?(?:\\* |  ).*?\n)*"

[feat|test|ref|fix|style](module) : A commit message
[feat|test|ref|fix|style](module) : A commit message

* first line
* second line
* and so on...
  • exclude-merge-commits : if set to true, will not check commit mesage for merge commit
  • check-summary-length : if set to true, check commit summary length, default is 50 characters
  • summary-length : you can override the default value summary length, which is 50 characters, this config is used only if check-summary-length is true

You can define as many matchers you want using regexp, naming is up to you, they will all be compared against a commit message till one match. Regexps used support comments, possessive match, positive lookahead, negative lookahead, positive lookbehind, negative lookbehind, back reference, named back referenc and conditionals.


Provided to help user to understand where is the problem, like matchers you can define as many examples as you want, they all will be displayed to the user if an error occured.

If you defined for instance :

[feat|test|ref|fix|style](module) : A commit message

this example will be displayed to the user like that :

A simple commit :

[feat|test|ref|fix|style](module) : A commit message

key is used as a title, underscore are replaced with withespaces.


Ensure your commit messages are consistent

  gommit [command]

Available Commands:
  check       Check ensure a message follows defined patterns
  version     App version

      --config string    (default ".gommit.toml")
  -h, --help            help for gommit

Use "gommit [command] --help" for more information about a command.
Check ensure a message follows defined patterns

  gommit check [flags]
  gommit check [command]

Available Commands:
  commit      Check commit message
  message     Check message
  range       Check messages in commit range

  -h, --help   help for check

Global Flags:
      --config string    (default ".gommit.toml")

Use "gommit check [command] --help" for more information about a command.

You need to provide two commit references to run matching for instance :
check commit

Check one comit from its commit ID, doesn't support short ID currently :

gommit check commit aeb603ba83614fae682337bdce9ee1bad1da6d6e

check message

Check a message, useful for script for instance when you want to use it with git hooks :

gommit check message "Hello"

check range

Check a commit range, useful if you want to use it with a CI to ensure all commits in branch are following your conventions :

  • with relative references : gommit check range master~2^ master
  • with absolute references : gommit check range dev test
  • with commit ids (doesn't support short ID currently) : gommit check range 7bbb37ade3ff36e362d7e20bf34a1325a15b 09f25db7971c100a8c0cfc2b22ab7f872ff0c18d

Practical usage

If your system isn't described here and you find a way to have gommit working on it, please improve this documentation by doing a PR for the next who would like to do the same.

Git hook

It's possible to use gommit to validate each commit when you are creating them. To do so, you need to use the commit-msg hook, you can replace default script with this one :


gommit check message "$(cat "$1")";

In travis, all history isn't cloned, default depth is 50 commits, you can change it : https://docs.travis-ci.com/user/customizing-the-build#Git-Clone-Depth.

First, we download the binary from the release page according to the version we want and we add in .travis.yml :

  - wget -O /tmp/gommit https://github.com/antham/gommit/releases/download/v2.0.0/gommit_linux_386 && chmod 777 /tmp/gommit

We can add a perl script in our repository to analyze the commit range against master for instance (master reference needs to be part of cloned history):


`git ls-remote origin master` =~ /([a-f0-9]{40})/;

my $refHead = `git rev-parse HEAD`;
my $refTail = $1;


if ($refHead eq $refTail) {
    exit 0;

system "gommit check range $refTail $refHead";

if ($? > 0) {
    exit 1;

And finally in .travis.yml, make it crashs when an error occured :

script: perl test-branch-commit-messages-in-travis.pl

In CircleCI (2.0), there is an environment variable that describe current branch : CIRCLE_BRANCH (https://circleci.com/docs/2.0/env-vars/#circleci-environment-variable-descriptions).

First, we download the binary from the release page according to the version we want and we add in .circleci/config.yml :

- run:
    name: Get gommit binary
    command: |
      mkdir /home/circleci/bin
      wget -O ~/bin/gommit https://github.com/antham/gommit/releases/download/v2.0.0/gommit_linux_386 && chmod 777 ~/bin/gommit

And we can run gommit against master for instance :

- run:
    name: Run gommit
    command: |
      ~/bin/gommit check range $(git rev-parse origin/master) $(git rev-parse ${CIRCLE_BRANCH})

Third Part Libraries

  • gommitjs : A Nodejs wrapper for gommit


The Go Gopher

There is no documentation for this package.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL