From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 uPkSJxTgImVJ8wAA9RJhRA:P1 (envelope-from ) for ; Sun, 08 Oct 2023 19:00:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id uPkSJxTgImVJ8wAA9RJhRA (envelope-from ) for ; Sun, 08 Oct 2023 19:00:04 +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 5A46669C34 for ; Sun, 8 Oct 2023 19:00:02 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Wqo8y62B; 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=1696784404; 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=hZ12fWCjJZiM5d6RBmhh6lpYb1LTFcRGe+Z1idpS4S8=; b=EyBawsiY19BWFGN3IPnh5SIunHQZV9gKE3yrtXsulH9Ytim18XHorpg8ROVBWFPEHJySrR CoYXles58zund3Pmzz3EvNqSb3/25dmreoVLl4QW0vl/6QpZmHO/CmmLVHARa6RbimMwal WAfqO9RnwoME5JhsWpxsWn/fyMy//48+gUIBjLzXQIheB1M7Kv2URc4cwtH0I1ytcl+Ugp 0iUn+aJzeQnc6A5hRfJnfHAIg331qJIYMxObkbJ6FzN4cs6vpnA4KPfdHihsu9qmHY789B FyAkHSDsGYzoYVa5cFURO5rY6YLZ34Tw+Gv8xWBG0DzyCxr1Y5uY3LTNL6FouQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696784404; a=rsa-sha256; cv=none; b=Qt+vgYwYZbuPgJk9DYw/flgf9QY/bP++kDcqzmDMs8zGE3OBv3rm5DinLTRvAXOXKxiTCX ezo6tL87uXelsyM9lfePS89D9UgJKnZgehARJmKJf1ciSgegh5r4eSrpIh/UT6Ubn7bwTF donk8rnXwpfN8qeDXX2EMksayfjgZ337DYyMvMNqUf4TSYBdmOkv86giQNKpU9l222jek4 4/lOuCtdVS9JbPDw5VGHJKGOKqAIb2E+JDNH3caX+XTfEjDq9l7LcUNfNzHVe615ucjA0C r0o3g7Wz/dMayRJCdimk70VsdagIdHsVDdJl0uSdLXRnJzpnWlws+l86n6cShA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Wqo8y62B; 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 1qpX85-0007ej-Pr; Sun, 08 Oct 2023 12:59:45 -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 1qpX84-0007eX-He for bug-guix@gnu.org; Sun, 08 Oct 2023 12:59: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 1qpX84-00050Q-A6 for bug-guix@gnu.org; Sun, 08 Oct 2023 12:59:44 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qpX8M-0004CJ-UQ; Sun, 08 Oct 2023 13:00:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#66027: [PATCH] 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, bug-guix@gnu.org, Giovanni Biscuolo Resent-Date: Sun, 08 Oct 2023 17:00: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 , Simon Tournier , Vagrant Cascadian , g@xelera.eu, ludo@gnu.org, Christopher Baines , Liliana Marie Prikler , Giovanni Biscuolo X-Debbugs-Original-Xcc: Giovanni Biscuolo Received: via spool by 66027-submit@debbugs.gnu.org id=B66027.169678435316045 (code B ref 66027); Sun, 08 Oct 2023 17:00:02 +0000 Received: (at 66027) by debbugs.gnu.org; 8 Oct 2023 16:59:13 +0000 Received: from localhost ([127.0.0.1]:58457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpX7Y-0004Aj-Nc for submit@debbugs.gnu.org; Sun, 08 Oct 2023 12:59:13 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]:48606) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpX7W-0004AU-T5 for 66027@debbugs.gnu.org; Sun, 08 Oct 2023 12:59:11 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1e1a2e26afcso2406620fac.1 for <66027@debbugs.gnu.org>; Sun, 08 Oct 2023 09:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696784325; x=1697389125; 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=hZ12fWCjJZiM5d6RBmhh6lpYb1LTFcRGe+Z1idpS4S8=; b=Wqo8y62BVgoLnREe8pP/qmX+jnkuln0bF114O3hJsey/xEFppfr6uj7j0H2tg/IiYI QszMnkwuThx7K1skNsFC0AJGs0Pyactxp8vJJEwRS3HfF0WD838JT7ikDpjiO9Hs8jC7 1VgfEBNsR08z2ldeGTrg8Tf8ml9q/4bvR0GpUPR/osQGhUaKQVLBDWwrfAxNJgkXtSMx hQPOwRIvDlyiIydqNrDC+7pCyySKSP5IEOlHflvfzvEdT+NUEsZXZaL7XCgzushww90y RKfAG6Qe+0Qnb0skcnySWRwNXa3iVMvBmpEjGLpKy7NKrJklo8z0E60kcVYBmQFRJG2H mUHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696784325; x=1697389125; 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=hZ12fWCjJZiM5d6RBmhh6lpYb1LTFcRGe+Z1idpS4S8=; b=Dw3zEEyEQ4uddzhGTES1gbNWYkexpVbuDOQWhyhbAbTFn8txcFkfQbgojI2Fd6LDLo BPvXhAbdre0UmkqHDz0gZ6UqTRu3qIrFzchgrEefH0ec5vlSKcQNrVORNio5EinqRxjt Pi4V1m7Zv5CEQnHI86EfDofSrzznvSNIEoKY85aW9B/4vkYbBFPLiXwWOOgfNPzCtLdX O0G5TKyr17SAWfOOzuALzUivH5UAuNBStbNmXIdU4mjlNdH4eXgs8BgdlZce7Rr/Jxzw l7ggCumeYTJaBT3NYP3SxjysBVLg3/P0mdK1hmG5Aio1Su8ZfoToVnuD3RVrCTINCe0e PbNQ== X-Gm-Message-State: AOJu0YwHfckTjBhbIjNT5mq8E+hEFTy19StBfjC+8M5/P0vpPGq6EMiT ifO2qEeD9+AhIxFT1KtFYLoJQ3J537Z0JA== X-Google-Smtp-Source: AGHT+IERSNJ2njx79sKGtsmlw7U2eqjhPlmC7Pl1GuTfu7EciHutFYhobiyi5aBG99cZONBApqKLxQ== X-Received: by 2002:a05:6870:7010:b0:1c0:5f7a:896f with SMTP id u16-20020a056870701000b001c05f7a896fmr15639928oae.8.1696784324694; Sun, 08 Oct 2023 09:58:44 -0700 (PDT) Received: from localhost.localdomain (dsl-158-21.b2b2c.ca. [66.158.158.21]) by smtp.gmail.com with ESMTPSA id c26-20020a0ca9da000000b0065b079366a7sm3175685qvb.114.2023.10.08.09.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 09:58:43 -0700 (PDT) From: Maxim Cournoyer Date: Sun, 8 Oct 2023 12:58:22 -0400 Message-ID: <9a58086598da5059232a05ce2a423e57e3ba997e.1696783796.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: 1.38 X-Spam-Score: 1.38 X-Migadu-Queue-Id: 5A46669C34 X-TUID: rTCWht/zpqGs 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 --- Makefile.am | 12 +++++- doc/contributing.texi | 10 ++++- etc/git/commit-msg | 92 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 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..0826f3a56e --- /dev/null +++ b/etc/git/commit-msg @@ -0,0 +1,92 @@ +#!/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) +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 +### 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: 9b77bd0b9b4f3de69390da0ba7db5b9dbc01e554 -- 2.41.0