rasch / git-hooks-commit-msg-validate

🦾 Git hooks for validating commit messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-hooks-commit-msg-validate

builds.sr.ht status

A commit-msg hook for validating commit messages. The rules are partially based on tpope's post: A Note About Git Commit Messages. The title line can optionally be prefixed with a gitmoji and a space before the subject.

Install

To use this hook, place it in the repository's .git/hooks/ directory. They can also be used as a plugins by running this git-hooks script to set up symlinks for each git hook and then cloning the repository to one of the following directories:

  • ~/.config/git/hooks/plugins/git-hooks-commit-msg-validate
  • .git/hooks/git-hooks-commit-msg-validate
  • .githooks/git-hooks-commit-msg-validate

Enforced Commit Message Formatting

Title Rules

  • No empty title line
  • Limit the title line length to 50 characters
  • Capitalize the first word of the title line (with an optional gitmoji + space prefix)
  • Remove trailing whitespace from the title line
  • Remove hard tabs (\t) from the title line
  • Remove punctuation from end of title line (?:!.,;)

Body Rules

  • Separate body from title with a blank line
  • Wrap the body text at 72 characters
  • Remove trailing whitespace from the body line(s)
  • Remove hard tabs (\t) from the body

Unenforced Rules

  • Begin with imperative verb in the subject line (Add, Fix, Remove, Update, etc).
  • Use the body to explain what and why instead of how.

Skip Commit Validation

git commit --no-verify

References

About

🦾 Git hooks for validating commit messages

License:BSD Zero Clause License


Languages

Language:Shell 100.0%