Add a default Git commit template message #476
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Git allows users to have "templates" for commits which, when they
exist, automatically fill the user's editor with the template contents
whenever they make a commit. This does not prevent the user from
further editing the commit message; all it does is pre-populate the
message with pre-written text.
In an effort to help improve the quality of commit messages on PHP
Mode, this patch introduces a commit template along with a Git hook
that, when applied, will automatically fill commit messages with
said template. The template has comments describing some basic
best-practices for writing Git messages, and has commented-out lines
of some metadata we use, i.e. lines like
This patch updates the Makefile with a new rule,
dev, that willinstall the hook. However, developers have another way to use the
template, which will be necessary for anyone who happens to already
be using the
prepare-commit-msghook for something: users can open.git/configin the project's top-level directory (tip:git rev-parse --show-toplevel) and add the following:This will apply the commit template for every commit. In contrast,
the hook will only use the template if it can determine the user does
not already have a template in place or that a different tool has
pre-populated the commit message with some text. So in that regard
the two approachs to using the template are different.
Signed-off-by: Eric James Michael Ritz ejmr@no.current.address