12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/bin/sh
- #
- # Every commit should have an issue reference at the start of the first line:
- echo Checking git message in $1
- (head -1 "$1" | grep -E -q "^gh-[0-9]+ ") || {
- echo >&2 "Missing GitHub issue"
- echo >&2 ""
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file"
- echo >&2 "Your git commit message should start with a line of the form"
- echo >&2 ""
- echo >&2 "gh-XXXX Short description"
- echo >&2 ""
- echo >&2 "where XXXX is the github issue number that this commit is referencing, and"
- echo >&2 "short description is a brief description of the issue that will appear in"
- echo >&2 "the --oneline version of the generated changelog."
- echo >&2 ""
- echo >&2 "Use git commit -s -t .git/COMMIT_EDITMSG to reopen previous message for editing"
- exit 1
- }
- (head -1 "$1" | grep -E -q "[^.]$") || {
- echo >&2 "Please don't use . at the end of the short description"
- echo >&2 ""
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file"
- echo >&2 "Your git commit message should start with a line of the form"
- echo >&2 ""
- echo >&2 "gh-XXXX Short description"
- echo >&2 ""
- echo >&2 "where XXXX is the github issue number that this commit is referencing, and"
- echo >&2 "short description is a brief description of the issue that will appear in"
- echo >&2 "the --oneline version of the generated changelog."
- echo >&2 ""
- echo >&2 "Use git commit -s -t .git/COMMIT_EDITMSG to reopen previous message for editing"
- exit 1
- }
- (head -1 "$1" | grep -E -q "^gh-[0-9]+ [^a-z]") || {
- echo >&2 "Short description should start with a capital"
- echo >&2 ""
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file"
- echo >&2 "Your git commit message should start with a line of the form"
- echo >&2 ""
- echo >&2 "gh-XXXX Short description"
- echo >&2 ""
- echo >&2 "where XXXX is the github issue number that this commit is referencing, and"
- echo >&2 "short description is a brief description of the issue that will appear in"
- echo >&2 "the --oneline version of the generated changelog."
- echo >&2 ""
- echo >&2 "Use git commit -s -t .git/COMMIT_EDITMSG to reopen previous message for editing"
- exit 1
- }
- (head -2 "$1" | tail -1 | grep -E -q "^$") || {
- echo >&2 "Short description must be followed by a blank line"
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file"
- exit 1
- }
- [ $(cat "$1" | wc -L ) -le 80 ] || {
- echo >&2 "Commit message lines too long."
- echo >&2 ""
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file."
- echo >&2 "Lines in the commit message should be no longer than 80 characters."
- echo >&2 ""
- echo >&2 "Use git commit -s -t .git/COMMIT_EDITMSG to reopen previous message for editing"
- exit 1
- }
- (grep -q "^Signed-off-by: " "$1") || {
- echo >&2 "Commit not signed."
- echo >&2 ""
- echo >&2 "Please see the guidelines for git commit messages in the CONTRIBUTORS file."
- echo >&2 "All commits should be signed (use git commit -s)."
- echo >&2 ""
- echo >&2 "Use git commit -s -t .git/COMMIT_EDITMSG to reopen previous message for editing"
- exit 1
- }
|