From de962c6566aeea1861151c07e2eb8fee1419373e Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko 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-default-branch-function'. (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 +`piem-name-branch-who-what-v'." + :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)))) subject) (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")) "fb/do-thing__v3")) (should-not (piem-name-branch-who-what-v - (list :from "Foo Bar ")))) + (list :from "Foo Bar "))) + ;; Test extra prefix. + (let ((piem-default-branch-prefix "prefix/")) + (should (equal (piem-name-branch-who-what-v + (list :from "Foo Bar " + :subject "[PATCH] Do a thing")) + "prefix/fb/do-thing")))) (ert-deftest piem--insert-message-id-header () (should-not -- 2.40.0