summaryrefslogtreecommitdiff
path: root/lisp/km-magit.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-12-31 11:41:04 -0500
committerKyle Meyer <kyle@kyleam.com>2017-12-31 11:45:45 -0500
commit363e8d35f47069deba4bb00ce46f8bd6cdaf5a2c (patch)
treee2099a9895c605a8ba7b75fed8837ed4a0a2a03c /lisp/km-magit.el
parenta6ea7d04f89b86531d96a016fcb1d58ba64b678e (diff)
downloademacs.d-363e8d35f47069deba4bb00ce46f8bd6cdaf5a2c.tar.gz
magit: Modify message for refs/pull/ merges
Diffstat (limited to 'lisp/km-magit.el')
-rw-r--r--lisp/km-magit.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index 1c84250..2a02e9d 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -121,6 +121,28 @@ branch."
(magit-merge it '("--ff-only"))
(user-error "No upstream branch")))
+;;;###autoload
+(defun km/magit-merge-pull-message (rev)
+ "Generate a PR merge message for REV.
+
+The PR message can take two forms:
+
+ 1) Merge branch '<local>' [#<pr>]
+ 2) Merge pull request #<pr> from <remote>/<branch>
+
+The first is used if REV is the name of a local branch, and the
+second if REV is the name of a remote branch.
+
+This assumes that you are pulling PRs into your 'refs/pull/'
+namespace."
+ (-when-let (pr (--when-let (magit-rev-name rev "refs/pull/*")
+ (and (string-match "\\`pull/.+/\\([0-9]+\\)\\'" it)
+ (match-string 1 it))))
+ (cond ((magit-local-branch-p rev)
+ (format "Merge branch '%s' [#%s]" rev pr))
+ ((magit-remote-branch-p rev)
+ (format "Merge pull request #%s from %s" pr rev)))))
+
(defun km/magit-push-all ()
"Push all branches."
(interactive)