Assign labels/milestones when creating an issue/pr
It would be nice to be able to assign labels and/or milestones when creating an issue or merge request in Magit Forge. Both forges I know (github and gitlab) offer this feature on the web UI, which simplifies workflows.
On github I currently have to create the topic, and then edit it twice (once for labels, then for milestones). Every one of those steps requires a new fetch.
I was hoping for a way to do all that in the same buffer for topic creation (and do a single topic fetch).
Asked first on emacs@SE: https://emacs.stackexchange.com/questions/68370/
Eventually I will likely implement this but it is not a high priority.
As mentioned in the SE answer, for Gitlab you can use quick actions to assign labels. Here's what I'm using to insert these easily in a new issue buffer:
(defvar fov/forge-insert-labels-hist)
(defun fov/forge-insert-labels ()
"Insert a /labels quick action."
(interactive)
(let ((repo (forge-get-repository nil))
(crm-separator ","))
(when (null repo) (error "Repo not found -- is this a new issue buffer?"))
(when-let (labels (magit-completing-read-multiple*
"Labels: "
(mapcar #'cadr (oref repo labels))
nil t nil 'fov/forge-insert-labels-hist))
(insert "/label "
(mapconcat (lambda (label)
(if (string-match-p "^[a-zA-Z0-9_?.&-]+$" label)
(concat "~" label)
(concat "~\"" label "\"")))
labels
" ")))))
;; Warning, clobbers a markdown mode binding
(define-key forge-post-mode-map (kbd "C-c C-l") #'fov/forge-insert-labels)