From 3664998a06b94dc86085e29185a45b400cfd4226 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 31 Aug 2026 09:36:35 +0100 Subject: forge: create branch from issue --- init.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'init.el') 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 -- cgit v1.2.3