Skip to content

Commit

Permalink
.hooks/prepare-commit-msg: Cleanup.
Browse files Browse the repository at this point in the history
Instead of writing everything in the new commit template all at once in
a large here document, do it cleanly one command at a time.
  • Loading branch information
mat813 committed Jun 4, 2021
1 parent fcbade2 commit d744a8d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ merge)
esac

outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX)
exec 3> "$outfile"

# Create a commit message template from three parts:
#
Expand All @@ -38,8 +39,9 @@ outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX)
# line to the end of the file) which lists files staged for commit, files
# not staged, and untracked files.

cat >"$outfile" <<EOF
$(awk '1;/^#$/{exit}' "$1")
awk '1;/^#$/{exit}' "$1" >&3

cat >&3 <<EOF
# category/port: Subject goes here, max 50 cols -|
# <then a blank line>
# 72 columns --|
Expand All @@ -65,7 +67,10 @@ $(awk '1;/^#$/{exit}' "$1")
#
# "Pull Request" and "Differential Revision" require the *full* GitHub or
# Phabricator URL.
$(awk '/^#$/,EOF' "$1")
EOF

awk '/^#$/,EOF' "$1" >&3

exec 3>&-

mv "$outfile" "$1"

0 comments on commit d744a8d

Please sign in to comment.