-
Notifications
You must be signed in to change notification settings - Fork 63
/
magithub-issue-tricks.el
56 lines (44 loc) · 2.01 KB
/
magithub-issue-tricks.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; magithub-issue-tricks.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2017-2018 Sean Allred
;; Author: Sean Allred <[email protected]>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'magit)
(require 'magithub-issue)
(defcustom magithub-hub-executable "hub"
"The hub executable used by Magithub."
:group 'magithub
:package-version '(magithub . "0.1")
:type 'string)
(defmacro magithub-with-hub (&rest body)
`(let ((magit-git-executable magithub-hub-executable)
(magit-pre-call-git-hook nil)
(magit-git-global-arguments nil))
,@body))
;;;###autoload
(defun magithub-pull-request-merge (pull-request &optional args)
"Merge PULL-REQUEST with ARGS.
See `magithub-pull-request--completing-read'. If point is on a
pull-request object, that object is selected by default."
(interactive (list (magithub-issue-completing-read-pull-requests)
(magit-am-arguments)))
(unless (executable-find magithub-hub-executable)
(user-error "This hasn't been supported in elisp yet; please install/configure `hub'"))
(unless (member pull-request (magithub-pull-requests))
(user-error "Unknown pull request %S" pull-request))
(let-alist pull-request
(magithub-with-hub
(magit-run-git-sequencer "am" args .html_url))
(message "#%d has been applied" .number)))
(provide 'magithub-issue-tricks)
;;; magithub-issue-tricks.el ends here