From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 6M6NEN4WJGXnGwAAauVa8A:P1 (envelope-from ) for ; Mon, 09 Oct 2023 17:06:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 6M6NEN4WJGXnGwAAauVa8A (envelope-from ) for ; Mon, 09 Oct 2023 17:06:06 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CF9036D01E for ; Mon, 9 Oct 2023 17:06:03 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=GHVeAfYE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1696863963; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=H2AmQBJG5gk5Poy3Pa32/fluUTrdWt8PkLkVRwFI21A=; b=Lqy9AlmNgcwjJHuc6ovkb8CXzNRP7os905VhS8RFm76nd86gtOQ4EdU8KEXIaxvsD5CO/5 fU0la42pDiMUFeR6cKJhFoVXsuLbKV1AcMqdOF99wUuL+arjPC4cn+FQPeHvDIjvOIkWcR 7Z+UOAYWpQ+EVnnVgtXFhLViZ9CojOGe4DBjil7q6196toNp7g0AgUjQCxunrKsaUk5pX9 mn/Ags4bzk2ZryjV2crcv/GEGSgPqRhDY4fFhnITfBEINoZINskHxrs+KfzWSSpiYQoMnw V70O5rGJaZ5jDxYU3HCKv9jP7y+SW5MCQ13pVqdMAbnsqbVaF1FakcMULY59JA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696863963; a=rsa-sha256; cv=none; b=rYaTxlpkZbJk/wwEsELFY8Wb/bIiYVSzLk+SouLwZuF9gVFE29FZCAZJSObDZKGcnjYMlV j/huMNnJHViJsqwdL+eL0fwnRBrEcVgX1omk1b97WO8Kzk+VjMYuK5WubWcOisCstmQcqz t6O2aAIy4HHJXZqWKnk2p+RL2KOqqw/k9jeocGYFfRceNovjTldEEmxRPDLYQfxLqaZ5K+ wQVti16ll2na5oFLOHBPB9N3D39kZ3VL4zzEYRjb5LGEN5lbcBRLoEwzPf4ASThfAvivYa rNn72DlRLPbSd9wG5C6Xim778kqMBCZUCX4OBRgZ4rAbo9BMGDOo2+7j2ExfYg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=GHVeAfYE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qprpN-0004mu-8S; Mon, 09 Oct 2023 11:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qprpI-0004la-BS for bug-guix@gnu.org; Mon, 09 Oct 2023 11:05:44 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qprpG-00084r-Sw for bug-guix@gnu.org; Mon, 09 Oct 2023 11:05:43 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qprpa-0000K0-Iv; Mon, 09 Oct 2023 11:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#66027: [PATCH v2] build: Add a commit-msg hook that embeds Change-Id in commit messages. References: <87fs3e792i.fsf@xelera.eu> In-Reply-To: <87fs3e792i.fsf@xelera.eu> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: g@xelera.eu, maxim.cournoyer@gmail.com, bug-guix@gnu.org, Giovanni Biscuolo Resent-Date: Mon, 09 Oct 2023 15:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66027 X-GNU-PR-Package: guix X-GNU-PR-Keywords: help moreinfo notabug To: 66027@debbugs.gnu.org Cc: Maxim Cournoyer , Giovanni Biscuolo , Maxim Cournoyer X-Debbugs-Original-Xcc: Giovanni Biscuolo , Maxim Cournoyer Received: via spool by 66027-submit@debbugs.gnu.org id=B66027.16968639131166 (code B ref 66027); Mon, 09 Oct 2023 15:06:02 +0000 Received: (at 66027) by debbugs.gnu.org; 9 Oct 2023 15:05:13 +0000 Received: from localhost ([127.0.0.1]:60691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qprom-0000Ij-Cw for submit@debbugs.gnu.org; Mon, 09 Oct 2023 11:05:12 -0400 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]:48528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qproj-0000IU-56 for 66027@debbugs.gnu.org; Mon, 09 Oct 2023 11:05:11 -0400 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-65b0c9fb673so24335096d6.1 for <66027@debbugs.gnu.org>; Mon, 09 Oct 2023 08:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696863882; x=1697468682; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=H2AmQBJG5gk5Poy3Pa32/fluUTrdWt8PkLkVRwFI21A=; b=GHVeAfYE8uu25zjDNgXKbZ8f8grUL+p1MD1jSzBYMHdLtKaek6vo/fQXz6h8DEvWhP BMDeeCVvE5Lvsd9FOtGeXphy/dY9gl1lHeOC7cq2sNCaxvrEegDSXL+DLyaRoKwpflrg mnoHn2DkFXV4ypv/wQDGJcrMWQ5TUSqTLpA7mwgxehBfuJdgjYHNFnrfLj3C5+SkmjqP ojJvVQKr7vCnwtcsBQAP2HWwysntzTyXS3W89a4tySInKhfQpels+KX76B8V4MnkM15O pi180k18PBJutwqEZoxh04pkt5HD6hL3RN/NoJ535SKDARk80q6QTHplDS/7g2f8bow+ X7fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696863882; x=1697468682; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H2AmQBJG5gk5Poy3Pa32/fluUTrdWt8PkLkVRwFI21A=; b=kSL7XSgEzJMQHBZlfI3e7TrIIR4++oiTEUcMNbPh2+syFk6gFI2uXnbRssLWAL9rSn Z54OYsyIjH6DrsTNKEv87FWuPVEyMqwen7yKr6aFQlwpw4reJPYasXy9Tuu/SwvrmWie dchd0tafGPrphoRkzZ7P0fXJeo38lxrFBwp8FW2xpfhHw4WZh+Fk/cFdYfq/mWuuRlLp ipsLz1xwIMWFPtceN8yZ+LmHH8a0h8RDFpF70VMEJ6pS7JtS52PsKKk7PetumdSCxmfF U5TQQ/korWQ4IvliaONa+HiiTiy1KBhrhomjVVPQj0715Vbjz9TFU6ZdIcVl6mPVZpEC Qt8w== X-Gm-Message-State: AOJu0YwROmrvdWQK4n77YTEDs78c99n0i0+FIfT0CVgqMwloot83b7oV Yh1aNJedkY+N0eNB2rgiS2/qTXb717c= X-Google-Smtp-Source: AGHT+IEF8KMB/84Cf2VU2KNK++/wvc96ivi1TolNSl02gmPK4JCRE2ed9Yuah1hUA8zDyk485DveKw== X-Received: by 2002:a05:6214:4a4c:b0:658:24e2:f237 with SMTP id ph12-20020a0562144a4c00b0065824e2f237mr13895973qvb.31.1696863882344; Mon, 09 Oct 2023 08:04:42 -0700 (PDT) Received: from localhost.localdomain (dsl-10-149-16.b2b2c.ca. [72.10.149.16]) by smtp.gmail.com with ESMTPSA id q11-20020a0ce20b000000b0065b13180892sm3917536qvl.16.2023.10.09.08.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:04:42 -0700 (PDT) From: Maxim Cournoyer Date: Mon, 9 Oct 2023 11:03:52 -0400 Message-ID: <5cf8fc887ccaf4e0d81828293ea5c1bb13e747fd.1696863754.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -0.11 X-Spam-Score: -0.11 X-Migadu-Queue-Id: CF9036D01E X-TUID: hpR14gSNIYee Partially implements . This will make it possible to track a merged commit back to its original posting on the mailing list, and open the door to new opportunities such as closing fully merged series automatically. * Makefile.am (COMMIT_MSG_MAGIC): New variable. (.git/hooks/commit-msg): New target. * etc/git/commit-msg: New file. * doc/contributing.texi (Configuring Git): Document Change-Id. Change-Id: Ia92fa958eae600fdd4e180bad494c85db8bb4dd6 --- Changes in v2: * Guard against nonexistant .git/hooks/commit-msg.d in commit-msg hook Makefile.am | 12 +++++- doc/contributing.texi | 10 ++++- etc/git/commit-msg | 94 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100755 etc/git/commit-msg diff --git a/Makefile.am b/Makefile.am index 310a231259..b860af7258 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1172,7 +1172,17 @@ cuirass-jobs: $(GOBJECTS) git config --add include.path ../etc/git/gitconfig; \ fi -nodist_noinst_DATA = .git/hooks/pre-push .git/config +COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= +.git/hooks/commit-msg: etc/git/commit-msg + $(AM_V_at)if test -d .git; then \ + if test -f $@ && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \ + mkdir -p $@.d && mv $@ $@.d && \ + @ echo user commit-msg hook moved to $@.d/commit-msg; \ + fi; \ + cp etc/git/commit-msg $@; \ + fi + +nodist_noinst_DATA = .git/hooks/pre-push .git/config .git/hooks/commit-msg # Downloading up-to-date PO files. diff --git a/doc/contributing.texi b/doc/contributing.texi index 864190b119..778bfb8fe6 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1575,8 +1575,16 @@ Configuring Git use @command{git config --local}, or edit @file{.git/config} in the repository instead of @file{~/.gitconfig}. +@cindex commit-msg hook Other important Git configuration will automatically be configured when -building the project (@pxref{Building from Git}). +building the project (@pxref{Building from Git}). A +@file{.git/hooks/commit-msg} hook will be installed that embeds +@samp{Change-Id} Git @emph{trailers} in your commit messages for +traceability purposes. It is important to preserve these when editing +your commit messages, particularly if a first version of your proposed +changes was already published. If you have a @file{commit-msg} hook of +your own you would like to use with Guix, you can place it under the +@file{.git/hooks/commit-msg.d/} directory. @node Sending a Patch Series @subsection Sending a Patch Series diff --git a/etc/git/commit-msg b/etc/git/commit-msg new file mode 100755 index 0000000000..dfa07918bb --- /dev/null +++ b/etc/git/commit-msg @@ -0,0 +1,94 @@ +#!/bin/sh +# From Gerrit Code Review 3.6.1 +# +# Part of Gerrit Code Review (https://www.gerritcodereview.com/) +# +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +### Guix modifications start +COMMIT_MSG_MAGIC=VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg= +top=$(git rev-parse --show-toplevel) +if test -d "$top/.git/hooks/commit-msg.d/"; then + for msg_hook in "$top/.git/hooks/commit-msg.d/"*; do + if ! sh "$msg_hook"; then + echo "error while running $msg_hook" + exit 1 + fi + done +fi +### Guix modifications end + +set -u + +# avoid [[ which is not POSIX sh. +if test "$#" != 1 ; then + echo "$0 requires an argument." + exit 1 +fi + +if test ! -f "$1" ; then + echo "file does not exist: $1" + exit 1 +fi + +# Do not create a change id if requested +if test "false" = "$(git config --bool --get gerrit.createChangeId)" ; then + exit 0 +fi + +if git rev-parse --verify HEAD >/dev/null 2>&1; then + refhash="$(git rev-parse HEAD)" +else + refhash="$(git hash-object -t tree /dev/null)" +fi + +random=$({ git var GIT_COMMITTER_IDENT ; echo "$refhash" ; cat "$1"; } | git hash-object --stdin) +dest="$1.tmp.${random}" + +trap 'rm -f "${dest}"' EXIT + +if ! git stripspace --strip-comments < "$1" > "${dest}" ; then + echo "cannot strip comments from $1" + exit 1 +fi + +if test ! -s "${dest}" ; then + echo "file is empty: $1" + exit 1 +fi + +reviewurl="$(git config --get gerrit.reviewUrl)" +if test -n "${reviewurl}" ; then + if ! git interpret-trailers --parse < "$1" | grep -q '^Link:.*/id/I[0-9a-f]\{40\}$' ; then + if ! git interpret-trailers \ + --trailer "Link: ${reviewurl%/}/id/I${random}" < "$1" > "${dest}" ; then + echo "cannot insert link footer in $1" + exit 1 + fi + fi +else + # Avoid the --in-place option which only appeared in Git 2.8 + # Avoid the --if-exists option which only appeared in Git 2.15 + if ! git -c trailer.ifexists=doNothing interpret-trailers \ + --trailer "Change-Id: I${random}" < "$1" > "${dest}" ; then + echo "cannot insert change-id line in $1" + exit 1 + fi +fi + +if ! mv "${dest}" "$1" ; then + echo "cannot mv ${dest} to $1" + exit 1 +fi base-commit: 87ffb3d3fbcc9273cb77f22e153ed31a70e2da11 -- 2.41.0