workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: konstantin@linuxfoundation.org
Cc: ksummit@lists.linux.dev, workflows@vger.kernel.org
Subject: [PATCH 1/3] b4: Move linktrailer to a LoreMessage property
Date: Tue, 14 Oct 2025 00:15:28 -0700	[thread overview]
Message-ID: <20251014071530.3665691-2-dan.j.williams@intel.com> (raw)
In-Reply-To: <20251014071530.3665691-1-dan.j.williams@intel.com>

In preparation for appending Link: trailers as 'git notes'. Arrange for a
submission link trailer to be a property of a message object.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 src/b4/__init__.py | 48 ++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index ffa7a5d5c7d9..c608a4d7956a 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -715,27 +715,7 @@ class LoreSeries:
             if lmsg is not None:
                 extras = list()
                 if addlink:
-                    linktrailer = None
-                    ltrmask = config.get('linktrailermask')
-                    if ltrmask and isinstance(ltrmask, str):
-                        if ltrmask.find(':'):
-                            lparts = ltrmask.split(':', maxsplit=1)
-                            llname = lparts[0].strip()
-                            llval = lparts[1].strip() % lmsg.msgid
-                            linktrailer = LoreTrailer(name=llname, value=llval)
-                        else:
-                            logger.critical('linktrailermask does not look like a valid trailer, using defaults')
-
-                    if not linktrailer:
-                        defmask = LOREADDR + '/r/%s'
-                        cfg_llval = config.get('linkmask', defmask)
-                        if isinstance(cfg_llval, str) and '%s' in cfg_llval:
-                            linktrailer = LoreTrailer(name='Link', value=cfg_llval % lmsg.msgid)
-                        else:
-                            logger.critical('linkmask does not look like a valid mask, using defaults')
-                            linktrailer = LoreTrailer(name='Link', value=defmask % lmsg.msgid)
-
-                    extras.append(linktrailer)
+                    extras.append(lmsg.linktrailer)
 
                 if attsame and not attcrit:
                     if attmark:
@@ -1258,6 +1238,7 @@ class LoreMessage:
         self._git_patch_id: Optional[str] = None
         self._pwhash: Optional[str] = None
         self._blob_indexes: Optional[Set[Tuple[str, str, str, str]]] = None
+        self._linktrailer: Optional[str] = None
 
         # Handle [PATCH 6/5]
         if self.counter > self.expected:
@@ -1399,6 +1380,31 @@ class LoreMessage:
                 self._blob_indexes = set()
         return self._blob_indexes
 
+    @property
+    def linktrailer(self) -> Optional[str]:
+        if self._linktrailer is None:
+            config = get_main_config()
+            ltrmask = config.get('linktrailermask')
+            if ltrmask and isinstance(ltrmask, str):
+                if ltrmask.find(':'):
+                    lparts = ltrmask.split(':', maxsplit=1)
+                    llname = lparts[0].strip()
+                    llval = lparts[1].strip() % self.msgid
+                    self._linktrailer = LoreTrailer(name=llname, value=llval)
+                else:
+                    logger.critical('linktrailermask does not look like a valid trailer, using defaults')
+
+            if self._linktrailer is None:
+                defmask = LOREADDR + '/r/%s'
+                cfg_llval = config.get('linkmask', defmask)
+                if isinstance(cfg_llval, str) and '%s' in cfg_llval:
+                    self._linktrailer = LoreTrailer(name='Link', value=cfg_llval % self.msgid)
+                else:
+                    logger.critical('linkmask does not look like a valid mask, using defaults')
+                    self._linktrailer = LoreTrailer(name='Link', value=defmask % self.msgid)
+
+        return self._linktrailer
+
     @property
     def attestors(self) -> List['LoreAttestor']:
         if self._attestors is not None:
-- 
2.51.0


  reply	other threads:[~2025-10-14  7:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14  7:15 [PATCH 0/3] b4: Add git notes for submission link trailers Dan Williams
2025-10-14  7:15 ` Dan Williams [this message]
2025-10-14  7:15 ` [PATCH 2/3] b4, ty: Move git_get_rev_diff to __init__ for reuse in post processing shazam Dan Williams
2025-10-14  7:15 ` [PATCH 3/3] mbox: Add a --add-link-note option to shazam Dan Williams
2025-10-14 18:28   ` dan.j.williams

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=20251014071530.3665691-2-dan.j.williams@intel.com \
    --to=dan.j.williams@intel.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=ksummit@lists.linux.dev \
    --cc=workflows@vger.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