summaryrefslogtreecommitdiff
path: root/magithub-issue-tricks.el
diff options
context:
space:
mode:
authorMatteo F. Vescovi <mfv@debian.org>2018-06-11 19:23:49 -0300
committerMatteo F. Vescovi <mfv@debian.org>2018-06-11 19:23:49 -0300
commit7dd1e35e345b4a318efcb14a25a8f5e3fdd0bd9e (patch)
treea9a20af2b86de431bfb9a1fefb82545c298d23a3 /magithub-issue-tricks.el
Import magithub_0.1.7.orig.tar.xz
[dgit import orig magithub_0.1.7.orig.tar.xz]
Diffstat (limited to 'magithub-issue-tricks.el')
-rw-r--r--magithub-issue-tricks.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/magithub-issue-tricks.el b/magithub-issue-tricks.el
new file mode 100644
index 0000000..09d0364
--- /dev/null
+++ b/magithub-issue-tricks.el
@@ -0,0 +1,56 @@
+;;; magithub-issue-tricks.el --- -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2017-2018 Sean Allred
+
+;; Author: Sean Allred <code@seanallred.com>
+
+;; 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