noelmansour / git-good-commit

Git hook to help you write good commit messages, with no external dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-good-commit

Git hook to help you write good commit messages.

Validates commit messages conform to six of the seven rules of a great git commit message, plus a couple of extras:

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how - you're on your own with this one
  8. Do no write single worded commits
  9. Do not start the subject line with whitespace

Installation

Single repository

At the root of the repository, run:

curl https://raw.githubusercontent.com/noelmansour/git-good-commit/master/hook.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg

Globally

To use the hook globally, you can use git-init's template directory:

mkdir -p ~/.git-template/hooks
git config --global init.templatedir '~/.git-template'
curl https://raw.githubusercontent.com/noelmansour/git-good-commit/master/hook.sh > ~/.git-template/hooks/commit-msg && chmod +x ~/.git-template/hooks/commit-msg

The hook will now be present after any git init or git clone. You can safely re-run git init on any existing repositories to add the hook there.


If you're security conscious, you may be reasonably suspicious of curling executable files. In this case you're on HTTPS throughout, and not piping directly to execution, so you can check contents and the hash against MD5 d83e5fd56f473d4190d0e03e736b3c2f for latest from master.

CI

ci-hook.sh can be used for CI builds. It behaves the same as hook.sh but simply exits on failure with a non-zero status code.

Credits

About

Git hook to help you write good commit messages, with no external dependencies.

License:MIT License


Languages

Language:Shell 100.0%