diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-02-02 15:14:35 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-02-23 17:23:57 +0100 |
commit | 8ab3d4890d8ef13279763b8f107586015f1c2402 (patch) | |
tree | 4bee7d6792344217ede70a8d8e7693a499e4e8c0 | |
parent | 01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91 (diff) | |
download | git-merge-pr-8ab3d4890d8ef13279763b8f107586015f1c2402.tar.gz git-merge-pr-8ab3d4890d8ef13279763b8f107586015f1c2402.tar.xz git-merge-pr-8ab3d4890d8ef13279763b8f107586015f1c2402.zip |
Rewrite commit message to close PR
-rwxr-xr-x | git-merge-pr | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/git-merge-pr b/git-merge-pr index 07a8386..1d72442 100755 --- a/git-merge-pr +++ b/git-merge-pr @@ -7,7 +7,7 @@ REMOTE= case "$PR" in *@*) REMOTE=${PR#*@} - PR=${PR%%@*};; + PR=${PR%%@*} esac shift @@ -17,7 +17,17 @@ PROJECT=${URL%.git} PROJECT=${PROJECT##*:} PROJECT=${PROJECT#//github.com/} -PATCH=$(mktemp) +PATCH="$(mktemp)" trap "rm -f $PATCH" INT TERM EXIT -wget -nv -O "$PATCH" https://github.com/$PROJECT/pull/$PR.patch +wget -nv -O "$PATCH" https://github.com/$PROJECT/pull/"$PR".patch git am "$@" "$PATCH" + +if [ "$(git config --bool --get merge-pr.autoclose)" = false ]; then + exit 0 +fi + +# Rewrite last commit message to close GitHub issue. +EDITOR='sh -c '\''git -c trailer.closes.ifExists=replace interpret-trailers \ + --trailer "Closes: #'"$PR"' [via git-merge-pr]" "$1" > "$1-" && + mv "$1-" "$1"'\'' -' \ +git commit --quiet --amend |