discussion and development of piem
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: piem@inbox.kyleam.com
Subject: [PATCH] New customization: `piem-default-branch-prefix'
Date: Sun, 30 Apr 2023 12:45:06 +0000	[thread overview]
Message-ID: <87cz3lsfn1.fsf@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]


Upon using piem for some time, I am getting hundreds of generated
branches in my repos. It gets inconvenient after some time, especially
because the branches are not always clearly distinguishable.

I'd like to add a new customization that adds a custom prefix string to
the generated branch names. That way, I can easily see the branches
generated by piem in the list of branches, nicely grouped when sorting

The patch is attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-customization-piem-default-branch-prefix.patch --]
[-- Type: text/x-patch, Size: 2525 bytes --]

From de962c6566aeea1861151c07e2eb8fee1419373e Mon Sep 17 00:00:00 2001
Message-Id: <de962c6566aeea1861151c07e2eb8fee1419373e.1682858544.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 30 Apr 2023 14:36:14 +0200
Subject: [PATCH] New customization: `piem-default-branch-prefix'

* piem.el (piem-default-branch-prefix): New custom option adding extra
prefix to the generated default branch name.  Only takes effect when
the default `piem-name-branch-who-what-v' is used as
(piem-name-branch-who-what-v): Use the new customization.
 piem.el             | 9 ++++++++-
 tests/piem-tests.el | 8 +++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/piem.el b/piem.el
index 63c358a..2334a3d 100644
--- a/piem.el
+++ b/piem.el
@@ -189,6 +189,12 @@ (defcustom piem-default-branch-function
       The reported base commit of the patch, if any."
   :type 'function)
+(defcustom piem-default-branch-prefix ""
+  "Optional prefix prepended to the generated branch name.
+Takes effect when `piem-default-branch-function' is set to
+  :type 'string)
 (defcustom piem-am-create-worktree nil
   "Whether to create a dedicated worktree for applying patches."
   :type 'boolean)
@@ -910,7 +916,8 @@ (defun piem-name-branch-who-what-v (info)
                               (zero-or-one (group "v" (one-or-more digit))))
                          (match-string 1 subject))))
-      (concat initials "/"
+      (concat piem-default-branch-prefix
+              initials "/"
               (piem--shorten-subject subject)
               (and version (concat "__" version))))))
diff --git a/tests/piem-tests.el b/tests/piem-tests.el
index 79d8591..ece762d 100644
--- a/tests/piem-tests.el
+++ b/tests/piem-tests.el
@@ -173,7 +173,13 @@ (ert-deftest piem-name-branch-who-what-v ()
                         :subject "[PATCH v3] Do a thing"))
   (should-not (piem-name-branch-who-what-v
-               (list :from "Foo Bar <xyz.com>"))))
+               (list :from "Foo Bar <xyz.com>")))
+  ;; Test extra prefix.
+  (let ((piem-default-branch-prefix "prefix/"))
+    (should (equal (piem-name-branch-who-what-v
+                    (list :from "Foo Bar <f@example.com>"
+                          :subject "[PATCH] Do a thing"))
+                   "prefix/fb/do-thing"))))
 (ert-deftest piem--insert-message-id-header ()

[-- Attachment #3: Type: text/plain, Size: 224 bytes --]

Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

             reply	other threads:[~2023-04-30 12:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30 12:45 Ihor Radchenko [this message]
2023-04-30 19:33 ` [PATCH] New customization: `piem-default-branch-prefix' Kyle Meyer
2023-04-30 20:11   ` Ihor Radchenko

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:

  List information: https://git.kyleam.com/

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

  git send-email \
    --in-reply-to=87cz3lsfn1.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=piem@inbox.kyleam.com \


* 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


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).