stgit icon indicating copy to clipboard operation
stgit copied to clipboard

RFE: Message-ID support

Open awilliam opened this issue 6 years ago • 7 comments

It would be useful if the Message-ID header could be extracted from email imports and optionally included in the commit log. For example, a new --msgid option to the import command would result in the following being appended to the commit log before any new sign-offs/acks/reviews: Message-Id: [email protected]

Ideally configuration options might allow the Message-Id string to be changed and the reference to be manipulated (via regex?), such that this same support could generate: Link: https://lore.kernel.org/r/[email protected]

This support would align well with better patch tracking that many maintainers are adopting. Thanks!

awilliam avatar Sep 24 '19 15:09 awilliam

Now that stgit uses mailinfo, this is just creating an option to use the -m flag. A hard coded variant is simply:

diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 92c7d59e44fe..0ccd39752473 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -364,7 +364,7 @@ def __import_mail_path(mail_path, filename, options):
     patch_path = mail_path + '-patch'
 
     mailinfo_lines = (
-        Run('git', 'mailinfo', msg_path, patch_path)
+        Run('git', 'mailinfo', '-m', msg_path, patch_path)
         .encoding(None)
         .decoding(None)
         .raw_input(mail)

awilliam avatar Mar 30 '21 15:03 awilliam

Is there a config or cmdline option to disable this behavior?

chucklever avatar Sep 30 '21 20:09 chucklever

No, should there be?

jpgrayson avatar Oct 01 '21 21:10 jpgrayson

The Linux kernel subsystem maintainer workflow uses lore, b4, and DKIM attestation, so generally a Message-ID: tag is not required or used. I plan to delete Message-ID: tags after importing patches from mailing lists, at least until such time as Message-ID: becomes a requirement for submitting patches to the Linux kernel. It would save me a step if stg import simply skipped adding them.

chucklever avatar Oct 03 '21 16:10 chucklever

Well, let me put this a better way. My impression is that when a reference to an e-mail is needed, a kernel commit requires a link to a permanent e-mail archive. Something like:

Link: https://lore.kernel.org/linux-nfs/163303597560.5125.8905823373792865984.stgit@klimt.1015granger.net/T/#u

Ah, now that I read the RFE text more closely, I see awilliam was asking for just such a thing.

Anyway, I will have to convert or delete each Message-Id: tag, which takes away some convenience.

chucklever avatar Oct 04 '21 13:10 chucklever

This is great context @chucklever, thank you. I think I was a bit too cavalier in turning-on this message-id copying behavior by default, sorry about that. I'm also guilty of overlooking key details in @awilliam's original request--sorry about that too.

Some options for the path forward:

  1. Add a command line option to enable this behavior, e.g. --message-id to mirror the git-mailinfo option name.
  2. Add a configuration option, e.g. stgit.import.messageid to enable this behavior. Default to disabled.
  3. Add a configuration option(s) to specify how to transform the message-id reference as @awilliam originally indicated (and that I overlooked).

Adding basic configurability (1 and 2) seems like a no-brainer. I'll take care of those.

But I'm not feeling super confident about designing 3. Seems like we'd need configuration options covering:

  • Regex to transform the message-id reference (stgit.import.msgidXlateRegex?). What form would we want this regex to take? Examples would be helpful.
  • Trailer name to go with the transformed reference (E.g. "Link") (stgit.import.msgidXlateTrailer)
  • An option to disable this behavior (stgit.import.msgidXlate)? Or is the absence of a regex sufficient?
  • Command line option variants of the above (to supplement the config options)?
  • Capability to do multiple transformations?

I'm looking for help specifying the desired behaviors as well as suggestions for naming of the config options.

jpgrayson avatar Oct 08 '21 14:10 jpgrayson

Thank you for reconsidering.

You probably want a hook for translating a message-id into a URL. The b4 tool appears to have a simple translation scheme. For example:

[email protected]

is converted into

https://lore.kernel.org/r/1633645823-31235-1-git-send-email-dwysocha%40redhat.com

Maybe a subcommand could be added to b4 to do only this translation, then stg mail could run that when needed? Other projects might provide a hook script to do this the way they like.

chucklever avatar Oct 08 '21 14:10 chucklever