From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id ay0/L7A9CGE6UwEAgWs5BA (envelope-from ) for ; Mon, 02 Aug 2021 20:47:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KHQvKrA9CGGFOwAAbx9fmQ (envelope-from ) for ; Mon, 02 Aug 2021 18:47:12 +0000 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 E412985FA for ; Mon, 2 Aug 2021 20:47:11 +0200 (CEST) Received: from localhost ([::1]:40860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAcxy-0004yk-Rq for larch@yhetil.org; Mon, 02 Aug 2021 14:47:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAcxq-0004w2-Hs for guix-patches@gnu.org; Mon, 02 Aug 2021 14:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAcxq-00058K-9y for guix-patches@gnu.org; Mon, 02 Aug 2021 14:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mAcxq-00011i-7P for guix-patches@gnu.org; Mon, 02 Aug 2021 14:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49796] [PATCH 1/2] etc/committer: Support custom commit messages. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 Aug 2021 18:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49796 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ricardo Wurmus Cc: 49796@debbugs.gnu.org Received: via spool by 49796-submit@debbugs.gnu.org id=B49796.16279299713880 (code B ref 49796); Mon, 02 Aug 2021 18:47:02 +0000 Received: (at 49796) by debbugs.gnu.org; 2 Aug 2021 18:46:11 +0000 Received: from localhost ([127.0.0.1]:39285 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAcx0-00010V-IY for submit@debbugs.gnu.org; Mon, 02 Aug 2021 14:46:10 -0400 Received: from out2.migadu.com ([188.165.223.204]:20385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAcwy-00010M-Oq for 49796@debbugs.gnu.org; Mon, 02 Aug 2021 14:46:09 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1627929966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3a1WEJFlx1lN4dxzhNQ/hQ6FZw0jYgIr98/htziVH2s=; b=KFEoldBsq/AV3iHt/zg9GrbbJpMuPYSAEP6nhU8XQAiFWDn34QMCOUXVbMUKldYPgNHMGB Kf1vMT3wql/4ML3SPZHTPcvQdgx11gWxia8a+aDoTpR2ncfSdXqh90+fqSSgjDXnt/ZY5X o4ElkcvjFR/zam/NM6mhfNis2tCxdlc= From: Sarah Morgensen References: <58ef8300317d11726eb2e9cd3e776485aaa95971.1627764883.git.iskarian@mgsn.dev> Date: Mon, 02 Aug 2021 11:46:04 -0700 In-Reply-To: <58ef8300317d11726eb2e9cd3e776485aaa95971.1627764883.git.iskarian@mgsn.dev> (Sarah Morgensen's message of "Sat, 31 Jul 2021 14:00:42 -0700") Message-ID: <86v94n4rdf.fsf@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1627930032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=3a1WEJFlx1lN4dxzhNQ/hQ6FZw0jYgIr98/htziVH2s=; b=hdw8R9oH2FH89LBz5rWSwGa2ajbGCgr/D5TSGotvoHugaz4kcO1jbCszavjpafrTsazWzi yMLYrbyUfbc7VtZ168Y2j1R8jsSxup17MghghqvwdJFXiZNlHIy3d0Gw+JkP8efZw3LBES 5dwi7z1DR0HbSh/S6b6ecxVnFXUMKu6iyJVuHpg1VcxlEa1tzskgKiKjo0Glwg8v0s8PwM jFIBH8fcaY1bpumypDd0Bdu0N6dF9enm1IaCdouDS3WRGpxGZjTEtE0PcAOx4BpwnJUYnW 0Mirte6FfMm01eJxC51hnlSZecijzbnJc1ypNDeZF6EWJekSaktG+p90Ri/5fw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1627930032; a=rsa-sha256; cv=none; b=F3uoYCOlmgRAu2sK+WSxbHthF6FIf9hiz4x0VP7uCNLw/UzW8wtGVwW81F4mYocpaRtanV NtSo9AIaW2cz1MI0UDNsZ+c8yKan3AwxzIqrodHFK8k+RKjtodWbuNnn8KyiUQq6kipFp8 sGoLv8xHJjRmMsC1egw6pUgPwoZGCyZTOSwMHlntemAZVUKbJ/DQInnBMBgqStN9l+A6sl KSMG5Tdh1GtyIP17b4NsmxpN2HJF+zxR3VDoDQfDo4pyX6EgJwYmdFgyqCM/pkyxAh89PS w6u9P/Ez2mC2LohB0Oh+s662+xgrYrrFR3z9NEWsBHjuB3pG9h5c4H6KRGg7BA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=KFEoldBs; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=KFEoldBs; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: E412985FA X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: vXWDrFaKwxob Hi Ricardo, I meant to X-Debbugs-CC you on this originally since it looks like etc/committer.scm is mostly your work, but I forgot. Hope you don't mind the ping. Sarah Morgensen writes: > Allow custom change commit messages by supplying a commit message and > optionally a changelog message as arguments. > > * etc/committer.scm.in (break-string-with-newlines) > (custom-commit-message): New procedures. > (main)[change-commit-message*]: New sub-procedure. Use them. > (main): Use it. > --- > Hello Guix, > > This allows supplying a commit message and optionally a ChangeLog message= as > arguments to committer.scm, which will be used as the message(s) for chan= ges > to definitions instead of "Update ..." Both support raw newlines, and if = the > changelog message contains ": ", no extra colon is added to the ChangeLog > message (this is to support custom definition specifiers). > > WDYT? > > -- > Sarah > etc/committer.scm.in | 55 +++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 49 insertions(+), 6 deletions(-) > > diff --git a/etc/committer.scm.in b/etc/committer.scm.in > index 96cd1fbf0b..ec831643af 100755 > --- a/etc/committer.scm.in > +++ b/etc/committer.scm.in > @@ -4,6 +4,7 @@ >=20=20 > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright =C2=A9 2020, 2021 Ricardo Wurmus > +;;; Copyright =C2=A9 2021 Sarah Morgensen > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -36,6 +37,7 @@ > (ice-9 popen) > (ice-9 match) > (ice-9 rdelim) > + (ice-9 regex) > (ice-9 textual-ports)) >=20=20 > (define* (break-string str #:optional (max-line-length 70)) > @@ -65,6 +67,13 @@ Return a single string." > (string-join (reverse (cons (restore-line last-words) lines)) > "\n")))))) >=20=20 > +(define* (break-string-with-newlines str #:optional (max-line-length 70)) > + "Break the lines of string STR into lines that are no longer than > +MAX-LINE-LENGTH. Return a single string." > + (string-join (map (cut break-string <> max-line-length) > + (string-split str #\newline)) > + "\n")) > + > (define (read-excursion port) > "Read an expression from PORT and reset the port position before retur= ning > the expression." > @@ -252,6 +261,32 @@ corresponding to the top-level definition containing= the staged changes." > "gnu: Add ~a.~%~%* ~a (~a): New variable.~%" > variable-name file-name variable-name)) >=20=20 > +(define* (custom-commit-message file-name variable-name message changelog > + #:optional (port (current-output-port))) > + "Print custom commit message for a change to VARIABLE-NAME in FILE-NAM= E, using > +MESSAGE as the commit message and CHANGELOG as the body of the ChangeLog > +entry. If CHANGELOG is #f, the commit message is reused. If CHANGELOG al= ready > +contains ': ', no colon is inserted between the location and body of the > +ChangeLog entry." > + (define (trim msg) > + (string-trim-right (string-trim-both msg) (char-set #\.))) > + > + (define (changelog-has-location? changelog) > + (->bool (string-match "^[[:graph:]]+:[[:blank:]]" changelog))) > + > + (let* ((message (trim message)) > + (changelog (if changelog (trim changelog) message)) > + (message/f (format #f "gnu: ~a: ~a." variable-name message)) > + (changelog/f (if (changelog-has-location? changelog) > + (format #f "* ~a (~a)~a." > + file-name variable-name changelog) > + (format #f "* ~a (~a): ~a." > + file-name variable-name changelog)))) > + (format port > + "~a~%~%~a~%" > + (break-string-with-newlines message/f 72) > + (break-string-with-newlines changelog/f 72)))) > + > (define (group-hunks-by-sexp hunks) > "Return a list of pairs associating all hunks with the S-expression th= ey are > modifying." > @@ -280,6 +315,15 @@ modifying." > (define %delay 1000) >=20=20 > (define (main . args) > + (define* (change-commit-message* file-name old new #:rest rest) > + (let ((changelog #f)) > + (match args > + ((or (message changelog) (message)) > + (apply custom-commit-message > + file-name (second old) message changelog rest)) > + (_ > + (apply change-commit-message file-name old new rest))))) > + > (match (diff-info) > (() > (display "Nothing to be done.\n" (current-error-port))) > @@ -325,13 +369,12 @@ modifying." > (error "Cannot apply"))) > (usleep %delay)) > hunks) > - (change-commit-message (hunk-file-name (first hunks)) > - old new > - (current-output-port)) > + (change-commit-message* (hunk-file-name (first hunks= )) > + old new) > (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-= F" "-"))) > - (change-commit-message (hunk-file-name (first hunk= s)) > - old new > - port) > + (change-commit-message* (hunk-file-name (first hun= ks)) > + old new > + port) > (usleep %delay) > (unless (eqv? 0 (status:exit-val (close-pipe port)= )) > (error "Cannot commit"))))) > > base-commit: daeef2e7f4f36df7a098c9aee7c03546d8691d39