문제

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

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top