diff options
| -rw-r--r-- | init.el | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |
