aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCătălin Mariș <alrraa@gmail.com>2015-11-30 22:27:43 +0200
committerMathias Bynens <mathias@qiwi.be>2015-12-01 13:30:02 +0100
commitcc5a019cef9becea233798541b2877b71ac6a4e8 (patch)
tree151e8f472402e141bb4ed13afd3c4eb378e378ff
parent82ff5bff91ff1e8c45e61c275b15845425888fa8 (diff)
downloaddotfiles-cc5a019cef9becea233798541b2877b71ac6a4e8.tar.gz
dotfiles-cc5a019cef9becea233798541b2877b71ac6a4e8.tar.bz2
dotfiles-cc5a019cef9becea233798541b2877b71ac6a4e8.zip
.gitconfig: Improve `mpr` command
Change the `mpr` command so that it merges the specified pull request into the current branch¹, or if a branch name is specified², into the specified branch. ¹ git mpr <number> ² git mpr <number> <branch_name> Closes #607.
-rw-r--r--.gitconfig10
1 files changed, 7 insertions, 3 deletions
diff --git a/.gitconfig b/.gitconfig
index 7a95a1a..5f2da62 100644
--- a/.gitconfig
+++ b/.gitconfig
@@ -60,12 +60,16 @@
# List contributors with number of commits
contributors = shortlog --summary --numbered
- # Merge GitHub pull request on top of the `master` branch
+ # Merge GitHub pull request on top of the current branch or,
+ # if a branch name is specified, on top of the specified branch
mpr = "!f() { \
+ declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \
+ declare branch=\"${2:-$currentBranch}\"; \
if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
git fetch origin refs/pull/$1/head:pr/$1 && \
- git rebase master pr/$1 && \
- git checkout master && \
+ git checkout -B $branch && \
+ git rebase $branch pr/$1 && \
+ git checkout -B $branch && \
git merge pr/$1 && \
git branch -D pr/$1 && \
git commit --amend -m \"$(git log -1 --pretty=%B)\n\nCloses #$1.\"; \