diff --git a/gitpr b/gitpr new file mode 100755 index 00000000..b726017f --- /dev/null +++ b/gitpr @@ -0,0 +1,19 @@ +#!/bin/zsh +# stop if not on master branch of local git repo +git branch | awk '$1~/\*/{if($2~/master/){exit 0}else{exit 1}}' +if [[ $? -ne 0 ]] ; then + echo "STOP: not on master branch of local git repo" + exit 1 +fi +# check manditory command-line argument, which is the pull request number +if [[ "$#" -ne 1 ]]; then + echo "ERROR: must specify exactly one command-line argument," + echo " the pull request number, NUM" + exit 1 +fi +NUM=$1 +# create local branch containing upstream pull request with NUM +git fetch upstream pull/$NUM/head:pr-$NUM +git checkout pr-$NUM +git status +exit 0 diff --git a/gitsync b/gitsync new file mode 100755 index 00000000..79a53b0b --- /dev/null +++ b/gitsync @@ -0,0 +1,15 @@ +#!/bin/bash +# stop if not on master branch of local git repo +git branch | awk '$1~/\*/{if($2~/master/){exit 0}else{exit 1}}' +if [ $? -ne 0 ]; then + echo "STOP: not on master branch of local git repo" + exit 1 +fi +# synchronize local git repo with central GitHub repo +git fetch upstream +git merge upstream/master +git push origin master +exit 0 + +# NOTE: to push branch to PR in GitHub repo, do this: +# git push upsteam