From 617e46152ff10be1785712324e128e4302f011a7 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Sat, 9 Nov 2019 15:21:08 -0600 Subject: [PATCH 1/2] add github-review --- modules/tools/magit/config.el | 1 + modules/tools/magit/packages.el | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 13a818dc3..764d35b21 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -110,6 +110,7 @@ ensure it is built when we actually use Forge." (dolist (hook forge-bug-reference-hooks) (add-hook hook #'forge-bug-reference-setup))))))) +(use-package! github-review) (use-package! magit-todos :after magit diff --git a/modules/tools/magit/packages.el b/modules/tools/magit/packages.el index c9e45de54..426dc4d95 100644 --- a/modules/tools/magit/packages.el +++ b/modules/tools/magit/packages.el @@ -5,5 +5,6 @@ (package! forge) (package! magit-gitflow) (package! magit-todos) + (package! github-review) (when (featurep! :editor evil +everywhere) (package! evil-magit))) From 89f4f9d88fc83c9a4255c255caa7d2e215d083db Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Sun, 1 Dec 2019 16:09:24 -0600 Subject: [PATCH 2/2] fix(magit): add bindings for github-review --- modules/tools/magit/autoload.el | 41 +++++++++++++++++++++++++++++++++ modules/tools/magit/config.el | 11 ++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/modules/tools/magit/autoload.el b/modules/tools/magit/autoload.el index bd42c1fdc..2cd1bda2e 100644 --- a/modules/tools/magit/autoload.el +++ b/modules/tools/magit/autoload.el @@ -93,3 +93,44 @@ control in buffers." (run-with-timer 5 nil #'+magit--kill-buffer buf) (kill-process process) (kill-buffer buf))))))) + +;;;###autoload +(defun +magit/start-github-review (arg) + (interactive "P") + (call-interactively + (if (or arg (not (featurep 'forge))) + #'github-review-start + #'github-review-forge-pr-at-point))) + +(defvar +magit-clone-history nil + "History for `+magit/clone' prompt.") +;;;###autoload +(defun +magit/clone (url-or-repo dir) + "Like `magit-clone', but supports additional formats on top of absolute URLs: + ++ USER/REPO: assumes {`+magit-default-clone-url'}/USER/REPO ++ REPO: assumes {`+magit-default-clone-url'}/{USER}/REPO, where {USER} is + ascertained from your global gitconfig." + (interactive + (progn + (require 'ghub) + (let* ((user (ghub--username (ghub--host))) + (repo (read-from-minibuffer + "Clone repository (user/repo or url): " + (if user (concat user "/")) + nil nil '+magit-clone-history)) + (name (car (last (split-string repo "/" t))))) + (list repo + (read-directory-name + "Destination: " + magit-clone-default-directory + name nil name))))) + (magit-clone-regular + (cond ((string-match-p "^[^/]+$" url-or-repo) + (require 'ghub) + (format +magit-default-clone-url (ghub--username (ghub--host)) url-or-repo)) + ((string-match-p "^\\([^/]+\\)/\\([^/]+\\)/?$" url-or-repo) + (apply #'format +magit-default-clone-url (split-string url-or-repo "/" t))) + (url-or-repo)) + dir + nil)) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 764d35b21..73a8508b3 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -110,7 +110,16 @@ ensure it is built when we actually use Forge." (dolist (hook forge-bug-reference-hooks) (add-hook hook #'forge-bug-reference-setup))))))) -(use-package! github-review) + +(use-package! github-review + :after magit + :config + (transient-append-suffix 'magit-merge "i" + '("y" "Review pull request" +magit/start-github-review)) + (after! forge + (transient-append-suffix 'forge-dispatch "c u" + '("c r" "Review pull request" +magit/start-github-review)))) + (use-package! magit-todos :after magit