From e16f2bb23d71bbecfed34437ec834b2b8a420209 Mon Sep 17 00:00:00 2001 From: Emile Vauge Date: Fri, 3 Feb 2017 11:41:58 +0100 Subject: [PATCH 1/3] Fix git rpr Signed-off-by: Emile Vauge --- .github/rpr.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/rpr.sh b/.github/rpr.sh index da7e8f9fc..e5f893ba0 100755 --- a/.github/rpr.sh +++ b/.github/rpr.sh @@ -4,9 +4,9 @@ set -e # stop on error -usage="$(basename "$0") pr -- rebase a Pull Request against current branch" +usage="$(basename "$0") pr remote/branch -- rebase a Pull Request against a remote branch" -if [ "$#" -ne 1 ]; then +if [ "$#" -ne 2 ]; then echo "Illegal number of parameters" echo "$usage" >&2 exit 1 @@ -16,20 +16,20 @@ command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. A set -x # echo on -base=$(git rev-parse --abbrev-ref HEAD) +initial=$(git rev-parse --abbrev-ref HEAD) pr=$1 +base=$2 remote=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.repo.owner.login) branch=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.ref) -git checkout $base +clean () +{ + .github/rmpr.sh $pr +} -git remote add $remote git@github.com:$remote/traefik.git -git fetch $remote $branch -git checkout -t $remote/$branch -git rebase origin/$base +trap clean EXIT + +.github/cpr.sh $pr + +git rebase $base git push -f $remote $branch - -# clean -git checkout $base -git branch -D $branch -git remote remove $remote \ No newline at end of file From 087bbd2e3ef676d4c8e17e51ad620b6e22293069 Mon Sep 17 00:00:00 2001 From: Emile Vauge Date: Mon, 6 Feb 2017 11:27:06 +0100 Subject: [PATCH 2/3] Add cpr command Signed-off-by: Emile Vauge --- .github/cpr.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 .github/cpr.sh diff --git a/.github/cpr.sh b/.github/cpr.sh new file mode 100755 index 000000000..18821a8fb --- /dev/null +++ b/.github/cpr.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# git config --global alias.cpr '!sh .github/cpr.sh' + +set -e # stop on error + +usage="$(basename "$0") pr -- Checkout a Pull Request locally" + +if [ "$#" -ne 1 ]; then + echo "Illegal number of parameters" + echo "$usage" >&2 + exit 1 +fi + +command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. Aborting." >&2; exit 1; } + +set -x # echo on + +initial=$(git rev-parse --abbrev-ref HEAD) +pr=$1 +remote=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.repo.owner.login) +branch=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.ref) + +git remote add $remote git@github.com:$remote/traefik.git +git fetch $remote $branch +git checkout -t $remote/$branch \ No newline at end of file From c00a9fae0c8675c19d5258a1c1329954455a9c6e Mon Sep 17 00:00:00 2001 From: Emile Vauge Date: Mon, 6 Feb 2017 11:46:03 +0100 Subject: [PATCH 3/3] Add rmpr command Signed-off-by: Emile Vauge --- .github/rmpr.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 .github/rmpr.sh diff --git a/.github/rmpr.sh b/.github/rmpr.sh new file mode 100755 index 000000000..03e818e88 --- /dev/null +++ b/.github/rmpr.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# git config --global alias.rmpr '!sh .github/rmpr.sh' + +set -e # stop on error + +usage="$(basename "$0") pr -- remove a Pull Request local branch & remote" + +if [ "$#" -ne 1 ]; then + echo "Illegal number of parameters" + echo "$usage" >&2 + exit 1 +fi + +command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. Aborting." >&2; exit 1; } + +set -x # echo on + +initial=$(git rev-parse --abbrev-ref HEAD) +pr=$1 +remote=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.repo.owner.login) +branch=$(curl -s https://api.github.com/repos/containous/traefik/pulls/$pr | jq -r .head.ref) + +# clean +git checkout $initial +git branch -D $branch +git remote remove $remote \ No newline at end of file