Add a feature to automatically close specified bug reports upon committing.

  • Open
  • quality assurance status badge
Details
4 participants
  • Felix Lechner
  • Giovanni Biscuolo
  • Maxim Cournoyer
  • Simon Tournier
Owner
Somebody
Submitted by
Giovanni Biscuolo
Severity
wishlist
G
G
Giovanni Biscuolo wrote on 16 Sep 2023 11:37
(address . bug-guix@gnu.org)
87fs3e792i.fsf@xelera.eu
Hello,

following a (lengthy) discussion on guix-devel [1] I propose to add the
new feature to our currently used server side post-receive git hook.

Some details about the implementation have been discussed with other
interested persons in [1] and I'll try to summarize them in this thread
Soon™.

To complete this feature request (wishlist) we need:

1. code implementation in the git hook _and_ testing

2. documentation ("Contributing" section)

3. installation on out git server

I'm going to take ownership of this bug (wishlist) but I'm not able to
do it on my own because I miss some info and authorization on the server
side.

(to be continued...)

Happy hacking! Gio'



--
Giovanni Biscuolo

Xelera IT Infrastructures
-----BEGIN PGP SIGNATURE-----

iQJABAEBCgAqFiEERcxjuFJYydVfNLI5030Op87MORIFAmUFd1YMHGdAeGVsZXJh
LmV1AAoJENN9DqfOzDkSW6EQAN+lOQU7aJlTzHZLj9f7uOez/ahT5NrrX6xLoDbv
+H5pVvzw+CNEzqAQzot1vpvSo1TPdTETH8BD+DUrfH5REkyJ4aQlbOXJ0z01fsgJ
FvwR1rMEklhZTk4kOU0Er/6p57aUzR9Xsl+Y6oWnqzAmRuhNmp+ZOwpZcuQNY055
89zCUIA0z3+O4zhFcStwiwGCKTcApjjWhWjPj12Kzxh665+IYXXvcMB2rEwWoKsY
tWMTonQ6VeKUbslp9nLAsszPJ6wXbq4ZIsyFbrsGbXiVJ9qtYYcxhNVlnYXqUTbV
C8vFdcYong9VL4CeIQQhs3zbyWTjnPxQWJ5ZrWvBU/DLz24vimZ+/PR3Qd2T455/
ARWjnd/MmyQZGak9GHwCaw9CldX/xwri0fqpqcakhnmrpFkakYxrDkXNA/HQXy+5
Yj/F/s8QTyooVSDh62fUBULAhkYWOPAbg1U62KlF2eQjKMnYZUpledCCoD4tgX+U
rszPd7TK5AkvfPENgUEGGkkNMJSx/FIsSSZYOSA0WKF5T7uzh0wGstemxCZ6eIht
af6/bm3BPf5ze3zLiDvgWpOnIFIZrs/p9OzUuysVEJPY0D/40RohAvElyMoT+kkB
g3xf0n41z2Qrv6xUnJvconmofHN+GxxDbF2pgfB9Bb0wUZui2kth0bcn9Wk9TZTr
Q1uP
=i/uF
-----END PGP SIGNATURE-----

G
G
Giovanni Biscuolo wrote on 16 Sep 2023 14:38
i command you...
(address . control@debbugs.gnu.org)
877coq70o3.fsf@xelera.eu
owner 66027 !
severity 66027 whishlist
tags 66027 notabug moreinfo help
quit

This is a new feature request so it's a wishlist.

I'll try to send patches, any help is very wellcome obviously!

Happy hacking, Gio'

--
Giovanni Biscuolo

Xelera IT Infrastructures
G
G
Giovanni Biscuolo wrote on 16 Sep 2023 14:47
(address . control@debbugs.gnu.org)
875y4a70aj.fsf@xelera.eu
severity 66027 wishlist
quit

Sorry fixing bad severity level!

--
Giovanni Biscuolo

Xelera IT Infrastructures
M
M
Maxim Cournoyer wrote on 8 Oct 2023 18:58
[PATCH] build: Add a commit-msg hook that embeds Change-Id in commit messages.
(address . 66027@debbugs.gnu.org)
9a58086598da5059232a05ce2a423e57e3ba997e.1696783796.git.maxim.cournoyer@gmail.com
Partially implements https://issues.guix.gnu.org/66027.

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

Toggle diff (147 lines)
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
M
M
Maxim Cournoyer wrote on 9 Oct 2023 17:03
[PATCH v2] build: Add a commit-msg hook that embeds Change-Id in commit messages.
(address . 66027@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
5cf8fc887ccaf4e0d81828293ea5c1bb13e747fd.1696863754.git.maxim.cournoyer@gmail.com
Partially implements https://issues.guix.gnu.org/66027.

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

Toggle diff (149 lines)
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
S
S
Simon Tournier wrote on 12 Oct 2023 15:54
86r0m02bfe.fsf@gmail.com
Hi,

On Mon, 09 Oct 2023 at 11:03, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:

Toggle quote (3 lines)
> + particularly if a first version of your proposed
> +changes was already published.

Sorry if my English is not good enough. Here, it is not clear for me
what “published” means. Does it mean “tracked” by Debbugs? If yes, I
would suggest:

particularly if a previous version of your proposed changes was
already submitted for review.

Cheers,
simon
M
M
Maxim Cournoyer wrote on 13 Oct 2023 05:33
[PATCH v3 1/3] build: Add a commit-msg hook that embeds Change-Id in commit messages.
(address . 66027@debbugs.gnu.org)
177d9176ef9d06a4ee51c271db982c15d7729a0e.1697168025.git.maxim.cournoyer@gmail.com
Partially implements https://issues.guix.gnu.org/66027.

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 <zimon.toutoune@gmail.com>
---

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

Toggle diff (149 lines)
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
M
M
Maxim Cournoyer wrote on 13 Oct 2023 05:33
[PATCH v3 2/3] gnu: patman: Apply patch for new Change-Id setting.
(address . 66027@debbugs.gnu.org)
3b95af8a90afdec5839a9de61dbcbccc5e842cb6.1697168025.git.maxim.cournoyer@gmail.com
* gnu/packages/bootloaders.scm (u-boot) [source]: Apply patch.
* gnu/packages/patches/u-boot-patman-change-id.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* .patman (keep_change_id): Use it.

Change-Id: I33c03013f6a260b5f5d80212b7b6ebe8a3f97efa
---

Changes in v3:
- New commit

.patman | 1 +
gnu/local.mk | 1 +
gnu/packages/bootloaders.scm | 3 +-
.../patches/u-boot-patman-change-id.patch | 232 ++++++++++++++++++
4 files changed, 236 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/u-boot-patman-change-id.patch

Toggle diff (275 lines)
diff --git a/.patman b/.patman
index 13fa4d0fab..efc42144a2 100644
--- a/.patman
+++ b/.patman
@@ -8,3 +8,4 @@ add_signoff: False
# TODO: enable check_patch
check_patch: False
ignore_bad_tags: True
+keep_change_id: True
diff --git a/gnu/local.mk b/gnu/local.mk
index 13c2b94944..39d833cee0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2052,6 +2052,7 @@ dist_patch_DATA = \
%D%/packages/patches/u-boot-fix-build-python-3.10.patch \
%D%/packages/patches/u-boot-fix-u-boot-lib-build.patch \
%D%/packages/patches/u-boot-nintendo-nes-serial.patch \
+ %D%/packages/patches/u-boot-patman-change-id.patch \
%D%/packages/patches/u-boot-rockchip-inno-usb.patch \
%D%/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch \
%D%/packages/patches/u-boot-rk3399-enable-emmc-phy.patch \
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 1124eca837..fb20ba0efa 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -654,7 +654,8 @@ (define u-boot
%u-boot-sifive-prevent-relocating-initrd-fdt
%u-boot-rk3399-enable-emmc-phy-patch
(search-patch "u-boot-fix-build-python-3.10.patch")
- (search-patch "u-boot-fix-u-boot-lib-build.patch")))
+ (search-patch "u-boot-fix-u-boot-lib-build.patch")
+ (search-patch "u-boot-patman-change-id.patch")))
(method url-fetch)
(uri (string-append
"https://ftp.denx.de/pub/u-boot/"
diff --git a/gnu/packages/patches/u-boot-patman-change-id.patch b/gnu/packages/patches/u-boot-patman-change-id.patch
new file mode 100644
index 0000000000..354aee2755
--- /dev/null
+++ b/gnu/packages/patches/u-boot-patman-change-id.patch
@@ -0,0 +1,232 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/patch/20231013030633.7191-1-maxim.cournoyer@gmail.com/
+
+From f83a5e07b0934e38cbee923e0c5b7fc0a890926c Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Thu, 12 Oct 2023 17:04:25 -0400
+Subject: [PATCH] patman: Add a 'keep_change_id' setting
+
+A Change-Id can be useful for traceability purposes, and some projects
+may wish to have them preserved. This change makes it configurable
+via a new 'keep_change_id' setting.
+
+Series-version: 2
+Series-changes: 2
+- Add missing argument to send parser
+---
+ tools/patman/__main__.py | 2 ++
+ tools/patman/control.py | 12 +++++++++---
+ tools/patman/patchstream.py | 17 ++++++++++++-----
+ tools/patman/patman.rst | 11 ++++++-----
+ tools/patman/test_checkpatch.py | 16 ++++++++++++++++
+ 5 files changed, 45 insertions(+), 13 deletions(-)
+
+diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
+index 8eba5d3486..197ac1aad1 100755
+--- a/tools/patman/__main__.py
++++ b/tools/patman/__main__.py
+@@ -103,6 +103,8 @@ send.add_argument('--no-signoff', action='store_false', dest='add_signoff',
+ default=True, help="Don't add Signed-off-by to patches")
+ send.add_argument('--smtp-server', type=str,
+ help="Specify the SMTP server to 'git send-email'")
++send.add_argument('--keep-change-id', action='store_true',
++ help='Preserve Change-Id tags in patches to send.')
+
+ send.add_argument('patchfiles', nargs='*')
+
+diff --git a/tools/patman/control.py b/tools/patman/control.py
+index 916ddf8fcf..b292da9dc2 100644
+--- a/tools/patman/control.py
++++ b/tools/patman/control.py
+@@ -16,11 +16,14 @@ from patman import gitutil
+ from patman import patchstream
+ from u_boot_pylib import terminal
+
++
+ def setup():
+ """Do required setup before doing anything"""
+ gitutil.setup()
+
+-def prepare_patches(col, branch, count, start, end, ignore_binary, signoff):
++
++def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
++ keep_change_id=False):
+ """Figure out what patches to generate, then generate them
+
+ The patch files are written to the current directory, e.g. 0001_xxx.patch
+@@ -35,6 +38,7 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff):
+ end (int): End patch to use (0=last one in series, 1=one before that,
+ etc.)
+ ignore_binary (bool): Don't generate patches for binary files
++ keep_change_id (bool): Preserve the Change-Id tag.
+
+ Returns:
+ Tuple:
+@@ -59,11 +63,12 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff):
+ branch, start, to_do, ignore_binary, series, signoff)
+
+ # Fix up the patch files to our liking, and insert the cover letter
+- patchstream.fix_patches(series, patch_files)
++ patchstream.fix_patches(series, patch_files, keep_change_id)
+ if cover_fname and series.get('cover'):
+ patchstream.insert_cover_letter(cover_fname, series, to_do)
+ return series, cover_fname, patch_files
+
++
+ def check_patches(series, patch_files, run_checkpatch, verbose, use_tree):
+ """Run some checks on a set of patches
+
+@@ -166,7 +171,8 @@ def send(args):
+ col = terminal.Color()
+ series, cover_fname, patch_files = prepare_patches(
+ col, args.branch, args.count, args.start, args.end,
+- args.ignore_binary, args.add_signoff)
++ args.ignore_binary, args.add_signoff,
++ keep_change_id=args.keep_change_id)
+ ok = check_patches(series, patch_files, args.check_patch,
+ args.verbose, args.check_patch_use_tree)
+
+diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
+index f91669a940..e2e2a83e67 100644
+--- a/tools/patman/patchstream.py
++++ b/tools/patman/patchstream.py
+@@ -68,6 +68,7 @@ STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit)
+ STATE_PATCH_HEADER = 2 # In patch header (after the subject)
+ STATE_DIFFS = 3 # In the diff part (past --- line)
+
++
+ class PatchStream:
+ """Class for detecting/injecting tags in a patch or series of patches
+
+@@ -76,7 +77,7 @@ class PatchStream:
+ unwanted tags or inject additional ones. These correspond to the two
+ phases of processing.
+ """
+- def __init__(self, series, is_log=False):
++ def __init__(self, series, is_log=False, keep_change_id=False):
+ self.skip_blank = False # True to skip a single blank line
+ self.found_test = False # Found a TEST= line
+ self.lines_after_test = 0 # Number of lines found after TEST=
+@@ -86,6 +87,7 @@ class PatchStream:
+ self.section = [] # The current section...END section
+ self.series = series # Info about the patch series
+ self.is_log = is_log # True if indent like git log
++ self.keep_change_id = keep_change_id # True to keep Change-Id tags
+ self.in_change = None # Name of the change list we are in
+ self.change_version = 0 # Non-zero if we are in a change list
+ self.change_lines = [] # Lines of the current change
+@@ -452,6 +454,8 @@ class PatchStream:
+
+ # Detect Change-Id tags
+ elif change_id_match:
++ if self.keep_change_id:
++ out = [line]
+ value = change_id_match.group(1)
+ if self.is_log:
+ if self.commit.change_id:
+@@ -763,7 +767,7 @@ def get_metadata_for_test(text):
+ pst.finalise()
+ return series
+
+-def fix_patch(backup_dir, fname, series, cmt):
++def fix_patch(backup_dir, fname, series, cmt, keep_change_id=False):
+ """Fix up a patch file, by adding/removing as required.
+
+ We remove our tags from the patch file, insert changes lists, etc.
+@@ -776,6 +780,7 @@ def fix_patch(backup_dir, fname, series, cmt):
+ fname (str): Filename to patch file to process
+ series (Series): Series information about this patch set
+ cmt (Commit): Commit object for this patch file
++ keep_change_id (bool): Keep the Change-Id tag.
+
+ Return:
+ list: A list of errors, each str, or [] if all ok.
+@@ -783,7 +788,7 @@ def fix_patch(backup_dir, fname, series, cmt):
+ handle, tmpname = tempfile.mkstemp()
+ outfd = os.fdopen(handle, 'w', encoding='utf-8')
+ infd = open(fname, 'r', encoding='utf-8')
+- pst = PatchStream(series)
++ pst = PatchStream(series, keep_change_id=keep_change_id)
+ pst.commit = cmt
+ pst.process_stream(infd, outfd)
+ infd.close()
+@@ -795,7 +800,7 @@ def fix_patch(backup_dir, fname, series, cmt):
+ shutil.move(tmpname, fname)
+ return cmt.warn
+
+-def fix_patches(series, fnames):
++def fix_patches(series, fnames, keep_change_id=False):
+ """Fix up a list of patches identified by filenames
+
+ The patch files are processed in place, and overwritten.
+@@ -803,6 +808,7 @@ def fix_patches(series, fnames):
+ Args:
+ series (Series): The Series object
+ fnames (:type: list of str): List of patch files to process
++ keep_change_id (bool): Keep the Change-Id tag.
+ """
+ # Current workflow creates patches, so we shouldn't need a backup
+ backup_dir = None #tempfile.mkdtemp('clean-patch')
+@@ -811,7 +817,8 @@ def fix_patches(series, fnames):
+ cmt = series.commits[count]
+ cmt.patch = fname
+ cmt.count = count
+- result = fix_patch(backup_dir, fname, series, cmt)
++ result = fix_patch(backup_dir, fname, series, cmt,
++ keep_change_id=keep_change_id)
+ if result:
+ print('%d warning%s for %s:' %
+ (len(result), 's' if len(result) > 1 else '', fname))
+diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
+index 038b651ee8..a8b317eed6 100644
+--- a/tools/patman/patman.rst
++++ b/tools/patman/patman.rst
+@@ -371,11 +371,12 @@ Series-process-log: sort, uniq
+ Separate each tag with a comma.
+
+ Change-Id:
+- This tag is stripped out but is used to generate the Message-Id
+- of the emails that will be sent. When you keep the Change-Id the
+- same you are asserting that this is a slightly different version
+- (but logically the same patch) as other patches that have been
+- sent out with the same Change-Id.
++ This tag is used to generate the Message-Id of the emails that
++ will be sent. When you keep the Change-Id the same you are
++ asserting that this is a slightly different version (but logically
++ the same patch) as other patches that have been sent out with the
++ same Change-Id. The Change-Id tag line is removed from outgoing
++ patches, unless the `keep_change_id` settings is set to `True`.
+
+ Various other tags are silently removed, like these Chrome OS and
+ Gerrit tags::
+diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
+index a8bb364e42..59a53ef8ca 100644
+--- a/tools/patman/test_checkpatch.py
++++ b/tools/patman/test_checkpatch.py
+@@ -160,6 +160,22 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
+
+ rc = os.system('diff -u %s %s' % (inname, expname))
+ self.assertEqual(rc, 0)
++ os.remove(inname)
++
++ # Test whether the keep_change_id settings works.
++ inhandle, inname = tempfile.mkstemp()
++ infd = os.fdopen(inhandle, 'w', encoding='utf-8')
++ infd.write(data)
++ infd.close()
++
++ patchstream.fix_patch(None, inname, series.Series(), com,
++ keep_change_id=True)
++
++ with open(inname, 'r') as f:
++ content = f.read()
++ self.assertIn(
++ 'Change-Id: I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413',
++ content)
+
+ os.remove(inname)
+ os.remove(expname)
+
+base-commit: f9a47ac8d97da2b3aaf463f268a9a872a8d921df
+--
+2.41.0
+
--
2.41.0
M
M
Maxim Cournoyer wrote on 13 Oct 2023 05:33
[PATCH v3 3/3] etc: teams: Parse 'From' commit more leniently.
(address . 66027@debbugs.gnu.org)
b350567a862fe6d49377ab8c2e1b8df0a007f141.1697168025.git.maxim.cournoyer@gmail.com
When a Change-Id is used, patman prepends a Message-Id field on the first line
of the patch, which broke the assumption that the 'From $commit' line must
appear on the first line.

* etc/teams.scm.in (git-patch->commit-id): Loop each line of the file until a
match is found. Update doc.

Change-Id: I20400f87469ffb761ffc82dd32e34cd06f619043
---

Changes in v3:
- New commit

etc/teams.scm.in | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

Toggle diff (28 lines)
diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index 55242caad1..703d76fe8d 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -770,13 +770,16 @@ (define (diff-revisions rev-start rev-end)
files))
(define (git-patch->commit-id file)
- "Parse the commit ID from the first line of FILE, a patch produced with git."
+ "Parse the commit ID from FILE, a patch produced with git."
(call-with-input-file file
(lambda (port)
- (let ((m (string-match "^From ([0-9a-f]{40})" (read-line port))))
- (unless m
- (error "invalid patch file:" file))
- (match:substring m 1)))))
+ (let loop ((line (read-line port)))
+ (when (eof-object? line)
+ (error "could not find 'from' commit in patch" file))
+ (let ((m (string-match "^From ([0-9a-f]{40})" line)))
+ (if m
+ (match:substring m 1)
+ (loop (read-line port))))))))
(define (git-patch->revisions file)
"Return the start and end revisions of FILE, a patch file produced with git."
--
2.41.0
S
S
Simon Tournier wrote on 23 Oct 2023 15:58
Re: bug#66027: Add a feature to automatically close specified bug reports upon committing.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87o7gpjv8g.fsf_-_@gmail.com
Hi Maxim,

If I read correctly, this series had been merged with:

fb3707762d * etc: teams: Parse 'From' commit more leniently.
f44fa21c3e * gnu: patman: Apply patch for new Change-Id setting.
8005e09b26 * build: Add a commit-msg hook that embeds Change-Id in commit messages.

Right?

Mark the submission as done? Or maybe is it a way for testing the
feature? ;-)

Cheers,
simon
M
M
Maxim Cournoyer wrote on 23 Oct 2023 22:09
(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
87wmvd5cea.fsf@gmail.com
Hi,

Simon Tournier <zimon.toutoune@gmail.com> writes:

Toggle quote (13 lines)
> Hi Maxim,
>
> If I read correctly, this series had been merged with:
>
> fb3707762d * etc: teams: Parse 'From' commit more leniently.
> f44fa21c3e * gnu: patman: Apply patch for new Change-Id setting.
> 8005e09b26 * build: Add a commit-msg hook that embeds Change-Id in commit messages.
>
> Right?
>
> Mark the submission as done? Or maybe is it a way for testing the
> feature? ;-)

It's only partially implementing the fix as mentioned in fb3707762d; the
missing bit is making use of the newly introduced Change-Id in mumi or a
script to determine if a series was fully merged, and close it if so.

So it should remain open until then :-).

--
Thanks,
Maxim
F
F
Felix Lechner wrote on 8 Feb 19:09 +0100
(no subject)
(address . control@debbugs.gnu.org)
87h6ii6d58.fsf@lease-up.com
reassign 65858 mumi
reassign 65809 mumi
reassign 49295 mumi
reassign 64833 mumi
reassign 54204 mumi
reassign 68920 mumi
reassign 55765 mumi
reassign 65923 mumi
reassign 63507 mumi
reassign 60226 mumi
reassign 63936 mumi
reassign 60951 mumi
reassign 66027 mumi
thanks
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 66027@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 66027
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch