tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Shubin <nikita.shubin@maquefel.me>
To: tools@linux.kernel.org
Cc: Nikita Shubin <nikita.shubin@maquefel.me>
Subject: [RFC PATCH] send: allow per patch To/Cc
Date: Mon, 24 Jul 2023 17:20:01 +0300	[thread overview]
Message-ID: <20230724142001.8104-1-nikita.shubin@maquefel.me> (raw)

Add "--per-patch-to-cc" option to send command to allow invoking cccmd
and tocmd individually per patch - this is usefull when sending series to
multiply subsystems.

Cover letter will still includes To: and Cc: gathered by "prep --auto-to-cc".

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
This makes b4 act as an old cocci_cc script, we gather emails by
--auto-to-cc, but then we can select email individually for each commit.
---
 b4/command.py |  2 ++
 b4/ez.py      | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/b4/command.py b/b4/command.py
index 1ae73d2..9dd5835 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -317,6 +317,8 @@ def setup_parser() -> argparse.ArgumentParser:
                          help='Send everything to yourself instead of the actual recipients')
     sp_send.add_argument('--no-trailer-to-cc', action='store_true', default=False,
                          help='Do not add any addresses found in the cover or patch trailers to To: or Cc:')
+    sp_send.add_argument('--per-patch-to-cc', action='store_true', default=False,
+                         help='Invoke individual tocmd, cccmd for each patch')
     sp_send.add_argument('--to', nargs='+', help='Addresses to add to the To: list')
     sp_send.add_argument('--cc', nargs='+', help='Addresses to add to the Cc: list')
     sp_send.add_argument('--not-me-too', action='store_true', default=False,
diff --git a/b4/ez.py b/b4/ez.py
index 3799e07..7925e31 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -1557,8 +1557,18 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
         if not cl_msgid:
             cl_msgid = b4.LoreMessage.get_clean_msgid(msg)
 
-        myto = list(allto)
-        mycc = list(allcc)
+        myto = list()
+        mycc = list()
+        if cmdargs.per_patch_to_cc and commit:
+            tocmd = get_to_cmd()
+            cccmd = get_cc_cmd()
+            msgbytes = msg.as_bytes()
+            myto = get_addresses_from_cmd(tocmd, msgbytes)
+            mycc = get_addresses_from_cmd(cccmd, msgbytes)
+        else:
+            myto = list(allto)
+            mycc = list(allcc)
+
         if msg['To']:
             myto += email.utils.getaddresses([msg['To']])
         if msg['Cc']:
@@ -2053,6 +2063,43 @@ def compare(compareto: str) -> None:
     logger.debug('Running %s', ' '.join(grdcmd))
     os.execvp(grdcmd[0], grdcmd)
 
+def get_to_cmd():
+    tocmdstr = None
+    topdir = b4.git_get_toplevel()
+    # Use sane tocmd and cccmd defaults if we find a get_maintainer.pl
+    getm = os.path.join(topdir, 'scripts', 'get_maintainer.pl')
+    config = b4.get_main_config()
+    if config.get('send-auto-to-cmd'):
+        tocmdstr = config.get('send-auto-to-cmd')
+    elif os.access(getm, os.X_OK):
+        tocmdstr = f'{getm} --nogit --nogit-fallback --nogit-chief-penguins --norolestats --nol'
+
+    tocmd = list()
+    if tocmdstr:
+        sp = shlex.shlex(tocmdstr, posix=True)
+        sp.whitespace_split = True
+        tocmd = list(sp)
+
+    return tocmd
+
+def get_cc_cmd():
+    cccmdstr = None
+    topdir = b4.git_get_toplevel()
+    # Use sane tocmd and cccmd defaults if we find a get_maintainer.pl
+    getm = os.path.join(topdir, 'scripts', 'get_maintainer.pl')
+    config = b4.get_main_config()
+    if config.get('send-auto-cc-cmd'):
+        cccmdstr = config.get('send-auto-cc-cmd')
+    elif os.access(getm, os.X_OK):
+        cccmdstr = f'{getm} --nogit --nogit-fallback --nogit-chief-penguins --norolestats --nom'
+
+    cccmd = list()
+    if cccmdstr:
+        sp = shlex.shlex(cccmdstr, posix=True)
+        sp.whitespace_split = True
+        cccmd = list(sp)
+
+    return cccmd
 
 def auto_to_cc() -> None:
     tocmdstr = None
-- 
2.39.2


                 reply	other threads:[~2023-07-24 14:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230724142001.8104-1-nikita.shubin@maquefel.me \
    --to=nikita.shubin@maquefel.me \
    --cc=tools@linux.kernel.org \
    /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.
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 NNTP newsgroup(s).