Browse Source

.hooks/prepare-commit-msg: Enhance commit-msg hook.

If a single port is updated, the hook now pre-fills in an appropriate
subject line.
main
Mathieu Arnold 5 months ago
parent
commit
5147b3b5e1
No known key found for this signature in database GPG Key ID: 29EB0902911D7E02
  1. 19
      .hooks/prepare-commit-msg

19
.hooks/prepare-commit-msg

@ -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

Loading…
Cancel
Save