From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id iHPGBiO7KGX8GAEA9RJhRA:P1 (envelope-from ) for ; Fri, 13 Oct 2023 05:36:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iHPGBiO7KGX8GAEA9RJhRA (envelope-from ) for ; Fri, 13 Oct 2023 05:36:03 +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 E3C2F4B56C for ; Fri, 13 Oct 2023 05:36:01 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Kse5BM6+; 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-Seal: i=1; s=key1; d=yhetil.org; t=1697168163; a=rsa-sha256; cv=none; b=slWZsXPVF+dAO4ENJ+h2n5c11Qxu9mdCjfTHTnKmnQjxkxP5dkPb3IfbVv53XbsLz3j5Jv uZ2BO05hwuq4QEwqOWZTCoGnB3+vT0hAFYlqe/tbIfVcj7jLZNEkSIhLzr5NBJzONogxjN 0wM+fQun6jtR1Udz7h0TJQDjIbo08FwuWvJdiRu3MUnykGG92/pOf9JoYA+U6XSy2e3wYJ WGsENZON+6ZTSyWuQ2XDZl2akw/Pt9zCOG6xHT94z03wvvX05drHNOLKacGgU4uo/PIvJK +yKOQnRxrheEWKiP2jJJOTC4e+8A29ID1hP+AHd0KHPRBNIn8DNvZwMD5hLRfg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Kse5BM6+; 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=1697168163; 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=pVUGZvD5Di5dQ+2xRcA0CVqxoW7pVEvTrsOUV5WW5nc=; b=qtwGbCeWxUerellxhtZupLb9ywUyrtgFocnWEOPCq3o3hcy3kpPyhBHA8wAa/w1tdsR2R5 YKz6qhTNOMkGWDfkhhkku6GMSxKFeGmZQR0xl2mapelbSHon6zrn/n2bQD63bk0N3W015g u9l7EqDD4ERAjrCrl48DN4IOZGCNA5Wng5+79PbI8hP7GC/wtPE8bTL9TPoztf//pQAHBZ Qdr8nGKjH7/8ViMYliQk1Bi4ZCJCiD81JWlxRH2MYY1iXrtZKXoilHIrH2hyTnH4s9sTPy eGcQp0XZsswB0SKg4IQIVlCv4IRAWR93KDvQvje4Le0NI9uI34wkBCTB5lZveg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qr8xk-0001vg-Sm; Thu, 12 Oct 2023 23:35:44 -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 1qr8xh-0001uO-1S for bug-guix@gnu.org; Thu, 12 Oct 2023 23:35:41 -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 1qr8xg-00018Y-PN for bug-guix@gnu.org; Thu, 12 Oct 2023 23:35:40 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qr8y1-0007vD-T9; Thu, 12 Oct 2023 23:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#66027: [PATCH v3 1/3] 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: bug-guix@gnu.org, Giovanni Biscuolo Resent-Date: Fri, 13 Oct 2023 03:36:01 +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: Giovanni Biscuolo , Maxim Cournoyer , Simon Tournier Received: via spool by 66027-submit@debbugs.gnu.org id=B66027.169716813830401 (code B ref 66027); Fri, 13 Oct 2023 03:36:01 +0000 Received: (at 66027) by debbugs.gnu.org; 13 Oct 2023 03:35:38 +0000 Received: from localhost ([127.0.0.1]:44525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qr8xd-0007uA-0T for submit@debbugs.gnu.org; Thu, 12 Oct 2023 23:35:38 -0400 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]:60675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qr8xZ-0007to-5S for 66027@debbugs.gnu.org; Thu, 12 Oct 2023 23:35:35 -0400 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-66d09b6d007so9502746d6.1 for <66027@debbugs.gnu.org>; Thu, 12 Oct 2023 20:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697168104; x=1697772904; 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=pVUGZvD5Di5dQ+2xRcA0CVqxoW7pVEvTrsOUV5WW5nc=; b=Kse5BM6+SRm4hTR5m5eyxP6zSaw9AWZUXVOo5RqlEzZpQIN1Or631HnP9IjvKlEvKU 6RQPo9/vTlfaud1drDtt2+rWXuJ8Izk3uxuKxEHRcUSSGpSwVhGba5yKDFOzG1zVMG4e aXgw+fXXWK1txq03AiY1C++OvbGSw9qiJMsHRZX6SoRqPxDJ5L3o2UmPvvyEf0eyOdBO jRarZKkwrT3aDo2w3iUkrZIS0cQ5EfKsTGaa35MyyAJKqWMFbYGkb0Vf/63WFid270z3 iSp6mgkiStClbIYg0JL4gZ8Q6RQEK2MNrkgFvQpqv0r9V0fws6sjPwUfNzOvy3Jsn9Zt vWvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697168104; x=1697772904; 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=pVUGZvD5Di5dQ+2xRcA0CVqxoW7pVEvTrsOUV5WW5nc=; b=LgHbDOyYT/DvDRyHaRBYjpoWEGDXCW2WNTswNfeNhW+vgjXGBfC8WfIXm4gkjPQ6xH jU2HZHUkzTyb3C0noLL/8B3MKFt/dUI3cLy969jIXibVjt56GCNfMkVoOYrDiiHyf1XB 9optRLEt5OZ64u3Fp1e2Ty7U2yaOthJ3Znw422NmhpP4hMJHf01cTkyq6rBUze8SAdyx y/yeQZhWIDE3KNSkR5AH9J/6YA8cyrPTTbOo1CUOtRcNdNsNt8lPDvFUVlz8/S55wEhH tsEfk12KURDbPM9Tw0MsSN9vnv5+vVemrda6FNynfxeGVvJAsmben4kliI62KZ2lN8Pl wu0g== X-Gm-Message-State: AOJu0YwXM3cnaJcdifbIEdnjLbWx7FlEpaOCs1KBOGAy+IZb91cqNahf oCJn/FF1ZAgSlTEEtGN9vIm28IIvJke7rg== X-Google-Smtp-Source: AGHT+IFTSuIRcrHfV4wCHhF6/49QX8OU0cZ9nI/D3io6QSlFnV4/F2KpTvNQx4afGtN4QhSKSjJAZg== X-Received: by 2002:a05:6214:c65:b0:66d:1256:6dbc with SMTP id t5-20020a0562140c6500b0066d12566dbcmr5389954qvj.44.1697168104451; Thu, 12 Oct 2023 20:35:04 -0700 (PDT) Received: from localhost.localdomain (dsl-10-128-66.b2b2c.ca. [72.10.128.66]) by smtp.gmail.com with ESMTPSA id v5-20020a0ccd85000000b00655e428604esm329512qvm.137.2023.10.12.20.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 20:35:03 -0700 (PDT) From: Maxim Cournoyer Date: Thu, 12 Oct 2023 23:33:43 -0400 Message-ID: <177d9176ef9d06a4ee51c271db982c15d7729a0e.1697168025.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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx1.migadu.com X-Migadu-Spam-Score: 7.80 X-Spam-Score: 7.80 X-Migadu-Queue-Id: E3C2F4B56C X-TUID: IEtPBQ5yNixI 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 Reviewed-by: Simon Tournier --- Changes in v3: - Clarify documentation text, as suggested by Simon 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..43cfae26c4 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 submitted for review. 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: 0c1d893b346d2fdbe7bb89b26fc913325b4bd57b -- 2.41.0