From owner-dev-commits-ports-all@freebsd.org Tue Apr 20 11:51:14 2021 Return-Path: Delivered-To: dev-commits-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 321685F289B; Tue, 20 Apr 2021 11:51:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FPhpp0vKcz4dmT; Tue, 20 Apr 2021 11:51:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 121E812581; Tue, 20 Apr 2021 11:51:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13KBpDi8022417; Tue, 20 Apr 2021 11:51:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13KBpDlw022416; Tue, 20 Apr 2021 11:51:13 GMT (envelope-from git) Date: Tue, 20 Apr 2021 11:51:13 GMT Message-Id: <202104201151.13KBpDlw022416@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Mathieu Arnold Subject: git: 043e196d694c - 2021Q2 - Add the prepare-commit-msg hook to the repository. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mat X-Git-Repository: ports X-Git-Refname: refs/heads/2021Q2 X-Git-Reftype: branch X-Git-Commit: 043e196d694c84978db30432358dd10ad90b3246 Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2021 11:51:14 -0000 The branch 2021Q2 has been updated by mat: URL: https://cgit.FreeBSD.org/ports/commit/?id=043e196d694c84978db30432358dd10ad90b3246 commit 043e196d694c84978db30432358dd10ad90b3246 Author: Mathieu Arnold AuthorDate: 2021-04-20 09:50:42 +0000 Commit: Mathieu Arnold CommitDate: 2021-04-20 11:50:57 +0000 Add the prepare-commit-msg hook to the repository. To make use of it, the easiest way is to run: git config --add core.hooksPath .hooks Discussed with: bapt (cherry picked from commit bbc2474ef7a65eb8561c8ecf7af80c2bfed1f248) --- .hooks/prepare-commit-msg | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.hooks/prepare-commit-msg b/.hooks/prepare-commit-msg new file mode 100755 index 000000000000..d2d1536cfcca --- /dev/null +++ b/.hooks/prepare-commit-msg @@ -0,0 +1,69 @@ +#!/bin/sh + +# prepare-commit-msg: Prepare a commit message upon `git commit` for the +# user to edit. A script (rather than a static template) is used, so +# that we can insert our template text other than at the top of the +# message. +# +# Install by either setting the configuration of the repository to: +# git config --add core.hooksPath .hooks +# or copy it to the hooks directory, but it will not get automatically updated: +# cp .hooks/prepare-commit-msg .git/hooks/ + +case "$2" in +commit|message) + # It appears git invokes this script for interactive rebase but does + # not remove commented lines, so just exit if we're not called with the + # default (comment-containing) template. + grep -E -q '^#' "$1" || exit 0 + ;; +template) + exit 0 + ;; +merge) + exit 0 + ;; +esac + +outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX) + +# Create a commit message template from three parts: +# +# 1. The beginning of the git-provided template (up to the first comment-only +# line) which explains commented lines and such. +# +# 2. Our template. +# +# 3. The remainder of the git-provided template (from the first comment-only +# line to the end of the file) which lists files staged for commit, files +# not staged, and untracked files. + +cat >"$outfile" < +# 72 columns --| +# +# Uncomment and complete these metadata fields, as appropriate: +# +# PR: +# Reported by: +# Reviewed by: +# Tested by: +# Approved by: +# Obtained from: +# Fixes: +# MFH: +# Relnotes: +# Security: +# Sponsored by: +# Pull Request: /pull/###> +# Differential Revision: +# +# "Pull Request" and "Differential Revision" require the *full* GitHub or +# Phabricator URL. The commit author should be set appropriately, using +# \`git commit --author\` if someone besides the committer sent in the change. +$(awk '/^#$/,EOF' "$1") +EOF + +mv "$outfile" "$1"