Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions Utilities/Hooks/commit-msg

This file was deleted.

43 changes: 39 additions & 4 deletions Utilities/Hooks/kw-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# limitations under the License.
#=============================================================================

# Ensure that the first arguement is a valid file for processing
if [ ! -f "$1" ]; then
echo "Missing input commit message file for the kw-commit-msg processing"
exit 1
fi

# Prepare a copy of the message:
# - strip comment lines
# - stop at "diff --git" (git commit -v)
Expand All @@ -29,8 +35,8 @@ To continue editing, run the command
die() {
echo 'commit-msg hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
echo '-----------------------' 1>&2
test -n "$die_advice" && echo "$die_advice" 1>&2
exit 1
}
Expand All @@ -48,7 +54,10 @@ msg_is_revert() {

msg_first() {
len=$(echo -n "$line" | wc -c)
max_len=$(hooks_config --get hooks.commit-msg.maxLength || echo 78) &&
# Use one of the following git commands to set the enforced subject maximum length.
# git config --global hooks.commit-msg.ITKCommitSubjectMaxLength 78
# git config --local hooks.commit-msg.ITKCommitSubjectMaxLength 78
max_len=$(git config --get hooks.commit-msg.ITKCommitSubjectMaxLength || echo 78) &&
if test $len -eq 0; then
# not yet first line
return
Expand All @@ -65,6 +74,26 @@ msg_first() {
elif echo "$line" | grep "^[ ]\|[ ]$" >/dev/null 2>&1; then
die 'The first line may not have leading or trailing space:
['"$line"']'

# Look for valid prefixes.
elif ! echo "$line" | egrep -q '^(Merge|Revert|BUG:|COMP:|DOC:|ENH:|PERF:|STYLE:|WIP:) ' > /dev/null 2>&1; then
die 'Start ITK commit messages with a standard prefix (and a space):
BUG: - fix for runtime crash or incorrect result
COMP: - compiler error or warning fix
DOC: - documentation change
ENH: - new functionality
PERF: - performance improvement
STYLE: - no logic impact (indentation, comments)
WIP: - Work In Progress not ready for merge
To reference GitHub issue XXXX, add "Issue #XXXX" to the commit message.
If the issue addresses an open issue, add "Closes #XXXX" to the message.'

# Reject bug number reference that CDash rejects.
elif echo "$line" | egrep -q '^BUG: [0-9][0-9]*\.'> /dev/null 2>&1; then
die 'Do not put a "." after the bug number:

'"$line"

else
# first line okay
state=second
Expand All @@ -74,8 +103,14 @@ msg_first() {
msg_second() {
if test "x$line" != "x"; then
die 'The second line must be empty:
'"$line"
'"\"$line\""
fi
state=third
}

msg_third() {
#Do nothing for 3rd -> Nth line
state=third
}

# Pipe commit message into the state machine.
Expand All @@ -84,5 +119,5 @@ cat "$commit_msg" |
while IFS='' read line; do
msg_$state || break
done &&
rm -f "$commit_msg" || exit 1
#rm -f "$commit_msg" || exit 1
die_advice='' # No more temporary message file.
Loading