all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 66027@debbugs.gnu.org
Cc: Giovanni Biscuolo <g@xelera.eu>,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>,
	Simon Tournier <zimon.toutoune@gmail.com>
Subject: bug#66027: [PATCH v3 3/3] etc: teams: Parse 'From' commit more leniently.
Date: Thu, 12 Oct 2023 23:33:45 -0400	[thread overview]
Message-ID: <b350567a862fe6d49377ab8c2e1b8df0a007f141.1697168025.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <177d9176ef9d06a4ee51c271db982c15d7729a0e.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(-)

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





  parent reply	other threads:[~2023-10-13  3:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-16  9:37 bug#66027: Add a feature to automatically close specified bug reports upon committing Giovanni Biscuolo
2023-10-08 16:58 ` bug#66027: [PATCH] build: Add a commit-msg hook that embeds Change-Id in commit messages Maxim Cournoyer
2023-10-09 15:03 ` bug#66027: [PATCH v2] " Maxim Cournoyer
2023-10-12 13:54   ` Simon Tournier
2023-10-13  3:33 ` bug#66027: [PATCH v3 1/3] " Maxim Cournoyer
2023-10-13  3:33   ` bug#66027: [PATCH v3 2/3] gnu: patman: Apply patch for new Change-Id setting Maxim Cournoyer
2023-10-13  3:33   ` Maxim Cournoyer [this message]
2023-10-23 13:58   ` bug#66027: Add a feature to automatically close specified bug reports upon committing Simon Tournier
2023-10-23 20:09     ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b350567a862fe6d49377ab8c2e1b8df0a007f141.1697168025.git.maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=66027@debbugs.gnu.org \
    --cc=g@xelera.eu \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.