2017-01-24 14:21:12 +00:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# git config --global alias.rpr '!sh .github/rpr.sh'
|
|
|
|
|
|
|
|
|
|
set -e # stop on error
|
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
usage="$(basename "$0") pr remote/branch -- rebase a Pull Request against a remote branch"
|
2017-01-24 14:21:12 +00:00
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
if [ "$#" -ne 2 ]; then
|
2017-01-24 14:21:12 +00:00
|
|
|
|
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
|
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
initial=$(git rev-parse --abbrev-ref HEAD)
|
2017-01-24 14:21:12 +00:00
|
|
|
|
pr=$1
|
2017-02-03 10:41:58 +00:00
|
|
|
|
base=$2
|
2017-01-24 14:21:12 +00:00
|
|
|
|
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)
|
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
clean ()
|
|
|
|
|
{
|
2017-02-06 14:31:45 +00:00
|
|
|
|
git checkout $initial
|
2017-02-03 10:41:58 +00:00
|
|
|
|
.github/rmpr.sh $pr
|
|
|
|
|
}
|
2017-01-24 14:21:12 +00:00
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
trap clean EXIT
|
|
|
|
|
|
|
|
|
|
.github/cpr.sh $pr
|
2017-01-24 14:21:12 +00:00
|
|
|
|
|
2017-02-03 10:41:58 +00:00
|
|
|
|
git rebase $base
|
|
|
|
|
git push -f $remote $branch
|