Question

Is there a way to have git warn you before finishing a commit, if the commit message does not contain a GitHub issue number?

Était-ce utile?

La solution

You can enable the client-side git hooks available on a per repo basis at .git/hooks. Inside this subdirectory you may find a bunch of samples. Here's a description of the hooks and how to use them.

In this case I think that the most suitable hook is commit-msg and you can check if the file that holds the proposed commit log message contains a susbtring in the form #123. For that purpose you could use the following regular expression:

$(grep '^.*#([1-9][0-9]*).*$' $1)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top