summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-06-06 12:27:02 -0400
committerKyle Meyer <kyle@kyleam.com>2020-06-06 15:15:02 -0400
commiteda0edf3efa9b87b72f9aeb3ac9a905fee0d205a (patch)
treef5329b2ec08550d404698a957b61dd4edcec6bda
parentb410f5acc57d42a323e9f828790c774b9d2138ce (diff)
downloadpiem-eda0edf3efa9b87b72f9aeb3ac9a905fee0d205a.tar.gz
Convert piem-am into a standalone command
b4 is great, and I have no desire to create an Elisp implementation of its complex patch series extraction. However, in cases where projects permit patches as attachments, using b4 isn't an option. And even for inline patches, it's useful to be able to git-am the patch associated with the current buffer. To support the above cases, teach piem-am to get an mbox from piem-am-ready-mbox when called interactively.
-rw-r--r--piem.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/piem.el b/piem.el
index b095bf1..eb725d0 100644
--- a/piem.el
+++ b/piem.el
@@ -375,6 +375,13 @@ in `piem-default-branch-function'."
(and version (concat "__" version))))))
(defun piem-am (mbox &optional info coderepo)
+ (interactive
+ (let ((mbox (or (piem-am-ready-mbox)
+ (user-error
+ "Could not find am-ready mbox for current buffer"))))
+ (list mbox
+ (piem-extract-mbox-info mbox)
+ (piem-inbox-coderepo-maybe-read))))
(let* ((default-directory (or coderepo default-directory)))
;; TODO: Optionally do more through Magit.
(let ((new-branch (read-string
@@ -393,7 +400,10 @@ in `piem-default-branch-function'."
(list "-b" new-branch))
(and (not (string-blank-p base))
(list base)))))
- (piem-process-call nil piem-git-executable "am" "--scissors" mbox)
+ (if (bufferp mbox)
+ (piem-process-call-with-buffer-input
+ nil mbox piem-git-executable "am" "--scissors")
+ (piem-process-call nil piem-git-executable "am" "--scissors" mbox))
(if (and piem-use-magit
(fboundp 'magit-status-setup-buffer))
(magit-status-setup-buffer)