From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id kLbbN1C6BWEPeAEAgWs5BA (envelope-from ) for ; Sat, 31 Jul 2021 23:02:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wPZqM1C6BWEkGAAAB5/wlQ (envelope-from ) for ; Sat, 31 Jul 2021 21:02:08 +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 71AA16992 for ; Sat, 31 Jul 2021 23:02:08 +0200 (CEST) Received: from localhost ([::1]:55922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9w7T-00018P-Bz for larch@yhetil.org; Sat, 31 Jul 2021 17:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9w7O-00018G-RX for guix-patches@gnu.org; Sat, 31 Jul 2021 17:02:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m9w7O-0004H6-JP for guix-patches@gnu.org; Sat, 31 Jul 2021 17:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m9w7O-0007Sz-IO for guix-patches@gnu.org; Sat, 31 Jul 2021 17:02: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: Sat, 31 Jul 2021 21:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49796 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49796@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162776526528629 (code B ref -1); Sat, 31 Jul 2021 21:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Jul 2021 21:01:05 +0000 Received: from localhost ([127.0.0.1]:34969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9w6T-0007Rg-C5 for submit@debbugs.gnu.org; Sat, 31 Jul 2021 17:01:05 -0400 Received: from lists.gnu.org ([209.51.188.17]:43368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9w6R-0007RX-2e for submit@debbugs.gnu.org; Sat, 31 Jul 2021 17:01:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9w6O-0000zr-OF for guix-patches@gnu.org; Sat, 31 Jul 2021 17:01:01 -0400 Received: from out2.migadu.com ([2001:41d0:2:aacc::]:33791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9w6H-0003MQ-QT for guix-patches@gnu.org; Sat, 31 Jul 2021 17:01:00 -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=1627765245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LorH+W12j5/5FOFLfSNL01hpUV5jFCUC+UKGe+FDpSg=; b=CrnYNGYw8dvqSx5VDp9HW6t/T6Rak11nGy+bsJBQBBGgKf4ckEj/v2AT2MSsibcApg04Wg Xm2JW0P5ED+h9KiIymrQ25dW6XpSdBOy+2GvQM36h17nS+5FtIhjBpJjRous4q2cnn9RVF bxBjPztkpAKrvff8LtvZqPBGgrXdv3E= From: Sarah Morgensen Date: Sat, 31 Jul 2021 14:00:42 -0700 Message-Id: <58ef8300317d11726eb2e9cd3e776485aaa95971.1627764883.git.iskarian@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Auth-User: iskarian@mgsn.dev Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=iskarian@mgsn.dev; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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=1627765328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=LorH+W12j5/5FOFLfSNL01hpUV5jFCUC+UKGe+FDpSg=; b=mV87QRPbch2dPs6Mn+7auaoVyU3YuGl61xyp7dXqpxKHT8ai1fLS0bkMtDFxjpMePfAak9 /Ew1/J1y5oie+9OLuoRZt6Kt3FeE1j+XROO9tr8adKLgPTKzI45lm7rQe7pEGgtnSUxVWB lcPF23+r5moGUtaxe/ZujXQCUHirxf/ts6N7lJwj0/wRGYCJVr1fUZICWFYreft+z/gtUb vhXfeqpbmFwGXGQl1jvkA62l0P0VC6jlT3NuOjCk4B9yMNnn92H5myeZDmo4TTPMAV9pTa +cBAWMO4enmpv6jqZtPMQppRsr6/TBAklvP1OkGKgVynswlDhtytkd0uOvK/eQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1627765328; a=rsa-sha256; cv=none; b=IJH5KL6B++TZFq2NUQE3cKuHoROqHEwyXxsQvAIWTes2Pnl1tc4E4FBxTYDCn7gt0SO3UR W+uLOJf/Z0e/okJGnROF/uMjUIoL4AUSbAokS/qB6fFHkvDaLRqFFZZUWrK0vGp1u6ic1o xitsdhpgWFxDi86kWlZ3FeYBLscorVG63tGYURbt8QnjIb8JvDMXsUB2TqJx4Hiu2LICEd iStQw/0p+owBYksBHYMq7QdgJ/ZLRhOqHVgqPjRgACV1nhwqPtTrNatWWPn1+BBcq8dUFu YqbkXKMTSqL1/ccn/Uaf4B4nE/NME3C5dkfjgIywTko06opOXGuXECJjeT459g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=CrnYNGYw; 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: -0.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=CrnYNGYw; 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: 71AA16992 X-Spam-Score: -0.32 X-Migadu-Scanner: scn1.migadu.com X-TUID: exlY3hlZP4D4 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 changes 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 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020, 2021 Ricardo Wurmus +;;; Copyright © 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)) (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")))))) +(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 returning 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)) +(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-NAME, 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 already +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 they are modifying." @@ -280,6 +315,15 @@ modifying." (define %delay 1000) (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 hunks)) - old new - port) + (change-commit-message* (hunk-file-name (first hunks)) + old new + port) (usleep %delay) (unless (eqv? 0 (status:exit-val (close-pipe port))) (error "Cannot commit"))))) base-commit: daeef2e7f4f36df7a098c9aee7c03546d8691d39 -- 2.31.1