Article View: linux.gentoo.dev
Article #59Re: [gentoo-dev] [PATCH infra/githooks v3] local/postrecv-bugs: only close bugs when pushing to specific branches
From: Sam James
Date: Sat, 24 Oct 2026 06:30
Date: Sat, 24 Oct 2026 06:30
130 lines
6109 bytes
6109 bytes
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Thomas Bracht Laumann Jespersen <laumann@gentoo.org> writes:
> Introduce a "gentoo.bugs.close-branches" config option, similar to the
> existing "gentoo.bugs.allowed-branches". When a commit with a
> "Closes:" trailer lands on an allowed branch, a comment is posted on
> the referenced bug, but only on "close-branches" will the bug be
> closed. Essentially, we treat "Closes:" like "Bug:" unless the branch
> being pushed to is on the "close-branches" list.
>
> For bugs that will be closed once they land on a branch in
> CLOSE_BRANCHES, we set their status to IN_PROGRESS.
>
> Closes: https://bugs.gentoo.org/980503
> Signed-off-by: Thomas Bracht Laumann Jespersen <laumann@gentoo.org>
> ---
Thank you! This looks good.
> v2 -> v3:
> - mention which branches commits should be pushed to for bug to be closed
> - Link to v2: https://archives.gentoo.org/gentoo-dev/20260925-close-branc=
hes-v2-1-8e141d06b6f3@gentoo.org
> ---
> local/postrecv-bugs | 32 +++++++++++++++++++++++++++++---
> 1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/local/postrecv-bugs b/local/postrecv-bugs
> index a64c6f7..ffba700 100755
> --- a/local/postrecv-bugs
> +++ b/local/postrecv-bugs
> @@ -1,6 +1,6 @@
> #!/bin/bash
> # gentoo-infra: infra/githooks.git:postrecv-bugs
> -# Copyright 2017-2024 Gentoo Authors
> +# Copyright 2017-2026 Gentoo Authors
> # Distributed under the terms of the GNU General Public License v2 or la=
ter
>=20=20
> # Author: Micha=C5=82 G=C3=B3rny <mgorny@gentoo.org>
> @@ -11,7 +11,12 @@ export TZ=3DUTC
>=20=20
> shopt -o -s noglob
>=20=20
> +# ALLOWED_BRANCHES lists all the branches that this hook is allowed to
> +# operate on to post comments or close bugs, and mark Codeberg PRs as
> +# closed/merged. CLOSE_BRANCHES lists the branches where closing bugs
> +# is permitted and is ideally a subset of ALLOWED_BRANCHES.
> ALLOWED_BRANCHES=3D$(git config --get gentoo.bugs.allowed-branches)
> +CLOSE_BRANCHES=3D$(git config --get gentoo.bugs.close-branches)
>=20=20
> declare -A COMMENT_BUGS=3D()
> declare -A CLOSE_BUGS=3D()
> @@ -30,6 +35,14 @@ while read -r oldrev newrev refname; do
> done
> [[ ${allowed} =3D=3D 0 ]] && continue
>=20=20
> + close_allowed=3D0
> + for close_branch in ${CLOSE_BRANCHES:-${ALLOWED_BRANCHES}}; do
> + if [[ ${refname#refs/heads/} =3D=3D ${close_branch} ]]; then
> + close_allowed=3D1
> + break
> + fi
> + done
> +
> while read -r commithash; do
> while read -r l; do
> is_fixes=3D0
> @@ -140,7 +153,20 @@ $(git show --pretty=3Dfuller --date=3Diso-local --st=
at "${commithash}")"
> done
>=20=20
> for bug in "${!CLOSE_BUGS[@]}"; do
> - msg=3D"The bug has been closed via the following commit(s):${CLOSE_B=
UGS[${bug}]}"
> + if [[ ${close_allowed} =3D=3D 1 ]]; then
> + msg=3D"The bug has been closed via the following commit(s):${CLO=
SE_BUGS[${bug}]}"
> + modify_args=3D( -s RESOLVED -r "${CLOSE_RESO[${bug}]}" )
> + else
> + # This case should only happen when CLOSE_BRANCHES is actually
> + # set, otherwise close_allowed should be true
> + branches=3D"${CLOSE_BRANCHES}"
> + if [[ "${branches}" =3D~ " " ]]; then
> + msg=3D"The bug will be closed when the following commits are=
pushed to || ( ${branches} ):${CLOSE_BUGS[${bug}]}"
> + else
> + msg=3D"The bug will be closed when the following commits are=
pushed to ${branches}:${CLOSE_BUGS[${bug}]}"
> + fi
> + modify_args=3D( -s IN_PROGRESS )
> + fi
>=20=20
> if [[ -n ${COMMENT_BUGS[${bug}]} ]]; then
> msg+=3D"
> @@ -148,7 +174,7 @@ for bug in "${!CLOSE_BUGS[@]}"; do
> Additionally, it has been referenced in the following commit(s):${COMMEN=
T_BUGS[${bug}]}"
> fi
>=20=20
> - bugz modify -s RESOLVED -r "${CLOSE_RESO[${bug}]}" -c "${msg}" "${bu=
g}"
> + bugz modify "${modify_args[@]}" -c "${msg}" "${bug}"
> done
>=20=20
> for bug in "${!COMMENT_BUGS[@]}"; do
>
> ---
> base-commit: 9993901cb7092dec6d09e5da94f28c8155909a0d
> change-id: 20260924-close-branches-f54e7b43ab2b
>
> Best regards,
--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmrcTmQbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z
Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx
QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkJ1F
AP42O8hvHDVnxGw1TlNDPpWYt02xw+CdjLt0T8VT3qgcYgEAp5LyjQME6tlu6ze0
BwW1j6wSnUSIGAy9on1yWH57zgA=
=1uHm
-----END PGP SIGNATURE-----
--=-=-=--
Technical Details
Message-ID:
<NRDqp-7xVc-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomodReferences:
<NIxWV-2qAT-1@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod From: Sam James <sam@gentoo.org> Newsgroups: linux.gentoo.dev Subject: Re: [gentoo-dev] [PATCH infra/githooks v3] local/postrecv-bugs: only close bugs when pushing to specific branches Date: Sat, 24 Oct 2026 08:30:01 +0200 Message-ID: <NRDqp-7xVc-1@gated-at.bofh.it> References: <NIxWV-2qAT-1@gated-at.bofh.it> X-Original-To: gentoo-dev@lists.gentoo.org Organization: Gentoo User-Agent: mu4e 1.14.4; emacs 32.0.50 List-ID: Gentoo Linux mail <gentoo-dev.gentoo.org> Reply-To: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Approved: robomod@news.nic.it Lines: 130 Sender: robomod@news.nic.it X-Original-Cc: Thomas Bracht Laumann Jespersen <laumann@gentoo.org> X-Original-Date: Sat, 24 Oct 2026 07:21:24 +0100 X-Original-Message-ID: <87jyn7d3ff.fsf@gentoo.org> X-Original-References: <20260929-close-branches-v3-1-c6c0d85d8020@gentoo.org>