Skip to content

Instantly share code, notes, and snippets.

@dopuskh3
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dopuskh3/33ef048d6ad12a56597a to your computer and use it in GitHub Desktop.
Save dopuskh3/33ef048d6ad12a56597a to your computer and use it in GitHub Desktop.

Perfect vim/git setup for clean commit messages

Install vim-git plugin (dopuskh3/vim-git add fancy color for commit message title) but the official plugin is fine too.

If you use Vundle:

Bundle "dopuskh3/vim-git"

Install git-commit-validator.py

From here:

https://gist.github.com/dopuskh3/bcf437f0f0c1293c9b2d

Use the following setup to validate commit message with the following constraints:

  • Title must starts with an infinitive word
  • No empty description
  • Line length to 50 for commit title
  • Line length to 72 for commit description
  • No more than one empty line between commit title and description
  • ~ other rules may come ~

Activate git-commit-validator while editing commit messages

autocmd Filetype gitcommit set makeprg=python\ /path/to/git-validate-commit.py\ %
autocmd Filetype gitcommit set efm=%l:%c:%m
autocmd BufWritePost COMMIT_EDITMSG make
@arnaudlamy
Copy link

An example of the perfect commit message will be great !

@dopuskh3
Copy link
Author

Here are some additional interesting list of topics to care about: https://wiki.openstack.org/wiki/GitCommitMessages#Information_in_commit_messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment