From 363e8d35f47069deba4bb00ce46f8bd6cdaf5a2c Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 31 Dec 2017 11:41:04 -0500 Subject: magit: Modify message for refs/pull/ merges --- lisp/km-magit.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lisp') 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 '' [#] + 2) Merge pull request # from / + +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) -- cgit v1.2.3