forge icon indicating copy to clipboard operation
forge copied to clipboard

Assign labels/milestones when creating an issue/pr

Open philsf opened this issue 4 years ago • 3 comments

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).

philsf avatar Sep 03 '21 22:09 philsf

Asked first on emacs@SE: https://emacs.stackexchange.com/questions/68370/

philsf avatar Sep 03 '21 22:09 philsf

Eventually I will likely implement this but it is not a high priority.

tarsius avatar Sep 04 '21 14:09 tarsius

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)

felipeochoa avatar Oct 21 '21 18:10 felipeochoa