unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Arun Isaac <arunisaac@systemreboot.net>
To: 63802@debbugs.gnu.org
Cc: Arun Isaac <arunisaac@systemreboot.net>,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#63802] [mumi PATCH 2/3] client: Add git-send-email-headers subcommand.
Date: Tue, 30 May 2023 13:14:46 +0100	[thread overview]
Message-ID: <20230530121447.26236-2-arunisaac@systemreboot.net> (raw)
In-Reply-To: <20230530121447.26236-1-arunisaac@systemreboot.net>

* mumi/client.scm: Import (rnrs exceptions).
(git-send-email-headers): New public function.
* scripts/mumi.in: Add git-send-email-headers subcommand.
---
 mumi/client.scm | 42 +++++++++++++++++++++++++++++++++++++++++-
 scripts/mumi.in |  2 ++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/mumi/client.scm b/mumi/client.scm
index 5befd42..c70fe61 100644
--- a/mumi/client.scm
+++ b/mumi/client.scm
@@ -17,6 +17,7 @@
 ;;; along with mumi.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (mumi client)
+  #:use-module (rnrs exceptions)
   #:use-module (rnrs io ports)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-19)
@@ -38,7 +39,9 @@
             print-current-issue
             set-current-issue!
             clear-current-issue!
-            send-email))
+            send-email
+            git-send-email-headers
+            compose))
 
 (define (git-top-level)
   "Return the top-level directory of the current git repository."
@@ -306,3 +309,40 @@ ISSUE-NUMBER."
                          "@"
                          (client-config 'debbugs-host))
           other-patches)))))
+
+(define (git-send-email-headers patch)
+  "Print send-email headers for PATCH."
+  (let* (;; Compute headers if configured in git config.
+         (header-command
+          (guard (ex (#t #f))
+            (call-with-input-pipe* (list "git" "config" "sendemail.headerCmd")
+              get-line)))
+         (headers
+          (if header-command
+              (call-with-input-pipe (string-append header-command " " patch)
+                get-string-all)
+              ""))
+         (external-x-debbugs-cc
+          (assq-ref (parse-email-headers
+                     (string-append (string-trim-right headers #\newline)
+                                    "\n"))
+                    'x-debbugs-cc))
+         ;; Fetch Cc addresses for current issue.
+         (x-debbugs-cc
+          (assq-ref (reply-email-headers (current-issue-number))
+                    'cc)))
+    ;; Print X-Debbugs-Cc header.
+    (when (or x-debbugs-cc external-x-debbugs-cc)
+      (display "X-Debbugs-Cc: ")
+      (display (if (and x-debbugs-cc external-x-debbugs-cc)
+                   (string-append x-debbugs-cc ", " external-x-debbugs-cc)
+                   (or x-debbugs-cc external-x-debbugs-cc)))
+      (newline))
+    ;; Print headers other than X-Debbugs-Cc.
+    ;; TODO: RFC5322 headers are not restricted to a single
+    ;; line. "Folded" multi-line headers are allowed. Support them.
+    (for-each (lambda (line)
+                (unless (string-prefix-ci? "X-Debbugs-Cc:" line)
+                  (display line)
+                  (newline)))
+              (string-split headers #\newline))))
diff --git a/scripts/mumi.in b/scripts/mumi.in
index 2295328..8fb7cd4 100644
--- a/scripts/mumi.in
+++ b/scripts/mumi.in
@@ -163,6 +163,8 @@
    (client:clear-current-issue!))
   (("send-email" . patches)
    (client:send-email patches))
+  (("git-send-email-headers" patch)
+   (client:git-send-email-headers patch))
   (("mailer" . rest)
    (let* ((opts (parse-options rest))
           (sender (assoc-ref opts 'sender))
-- 
2.39.2





  reply	other threads:[~2023-05-30 12:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 12:11 [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Arun Isaac
2023-05-30 12:14 ` [bug#63802] [mumi PATCH 1/3] client: Do not pass --add-header to git send-email Arun Isaac
2023-05-30 12:14   ` Arun Isaac [this message]
2023-06-05  2:31     ` [bug#63802] [mumi PATCH 2/3] client: Add git-send-email-headers subcommand Maxim Cournoyer
2023-06-08 17:09       ` Arun Isaac
2023-06-08 17:29         ` Arun Isaac
2023-05-30 12:14   ` [bug#63802] [mumi PATCH 3/3] client: Use mumi " Arun Isaac
2023-06-05  2:36     ` Maxim Cournoyer
2023-06-05  2:21   ` [bug#63802] [mumi PATCH 1/3] client: Do not pass --add-header to git send-email Maxim Cournoyer
2023-06-08 17:14 ` [bug#63802] [PATCH 1/3] client: Separate serialize-email-address into a function Arun Isaac
2023-06-08 17:14   ` [bug#63802] [PATCH 2/3] client: Add git-send-email-headers subcommand Arun Isaac
2023-07-16  3:39     ` [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Maxim Cournoyer
2023-07-17 22:14       ` Arun Isaac
2023-07-18 15:32         ` Maxim Cournoyer
2023-07-19 16:49           ` bug#63802: " Arun Isaac
2023-06-08 17:14   ` [bug#63802] [PATCH 3/3] client: Use mumi git-send-email-headers subcommand Arun Isaac
2023-07-16  4:01     ` [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Maxim Cournoyer
2023-07-17 22:14       ` Arun Isaac
2023-07-16  3:14   ` Maxim Cournoyer
2023-07-17 22:19 ` [bug#63802] [PATCH 1/3] client: Separate serialize-email-address into a procedure Arun Isaac
2023-07-17 22:19   ` [bug#63802] [PATCH 2/3] client: Add git-send-email-headers subcommand Arun Isaac
2023-07-17 22:19   ` [bug#63802] [PATCH 3/3] client: Use mumi " Arun Isaac

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20230530121447.26236-2-arunisaac@systemreboot.net \
    --to=arunisaac@systemreboot.net \
    --cc=63802@debbugs.gnu.org \
    --cc=maxim.cournoyer@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).