Skip to content

Commit

Permalink
.hooks/prepare-commit-msg: Enhance commit-msg hook.
Browse files Browse the repository at this point in the history
If a single port is updated, the hook now pre-fills in an appropriate
subject line.
  • Loading branch information
mat813 committed Jun 4, 2021
1 parent d744a8d commit 5147b3b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ esac
outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX)
exec 3> "$outfile"

if [ -z "$3" ]
then
what=$(git diff-index --name-only --cached --diff-filter=ACMR HEAD|sed -Ee 's/^([^\/]+\/[^\/]+).*/\1/'|sort -u|xargs)

case $what in
*\ *)
# More than one port, do nothing
;;
*)
# One port, prepare the commit message.
{
echo "# Uncomment and add a short description of why things changed."
echo "# $what: "
echo
} >&3
;;
esac
fi

# Create a commit message template from three parts:
#
# 1. The beginning of the git-provided template (up to the first comment-only
Expand Down

0 comments on commit 5147b3b

Please sign in to comment.