summaryrefslogtreecommitdiffhomepage
path: root/init.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-08-31 09:36:35 +0100
committerjao <jao@gnu.org>2026-08-31 09:37:07 +0100
commit3664998a06b94dc86085e29185a45b400cfd4226 (patch)
tree204c4bcfb03d1b0cf628f352cb6963d44b4f1628 /init.el
parentb87794e281aa198a95842a3cecf29c908c3eb15f (diff)
downloadelibs-3664998a06b94dc86085e29185a45b400cfd4226.tar.gz
elibs-3664998a06b94dc86085e29185a45b400cfd4226.tar.bz2
forge: create branch from issue
Diffstat (limited to 'init.el')
-rw-r--r--init.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/init.el b/init.el
index 03e0eba..31a42c1 100644
--- a/init.el
+++ b/init.el
@@ -1681,6 +1681,23 @@
:config
:bind ((:map forge-topic-mode-map ("M-w" . copy-region-as-kill))))
+(defun jao-forge-create-branch-from-issue ()
+ "Create and checkout a git branch named after the Forge issue at point."
+ (interactive)
+ (let* ((topic (or (forge-current-topic) (user-error "No issue at point")))
+ (id (oref topic number))
+ (title (oref topic title))
+ ;; Clean up the title to make it a valid git branch name
+ (clean-title (downcase (replace-regexp-in-string "[^a-zA-Z0-9]+" "-" title)))
+ (branch-name (format "jao-%d-%s" id (string-trim clean-title "-")))
+ (branch-name (read-string "Create branch: " branch-name)))
+ (magit-branch-and-checkout branch-name (magit-get-current-branch))))
+
+;; Optional: Bind it to 'b i' inside Magit status/issue buffers
+(with-eval-after-load 'magit
+ (transient-insert-suffix 'magit-branch "s"
+ '("i" "branch from issue" jao-forge-create-branch-from-issue)))
+
;;;; forgejo
(use-package forgejo
:ensure t