Update Marlin+Github helper scripts

This commit is contained in:
Scott Lahteine
2017-07-02 20:43:57 -05:00
parent 015839fc50
commit ab79933d1f
12 changed files with 94 additions and 93 deletions

View File

@ -2,47 +2,55 @@
#
# mfup
#
# Fetch and merge upstream changes, optionally with a branch
# - Fetch latest upstream and replace the PR Target branch with
# - Rebase the (current or specified) branch on the PR Target
# - Force-push the branch to 'origin'
# -
#
MFINFO=$(mfinfo) || exit
[[ $# < 2 ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
MFINFO=$(mfinfo "$@") || exit 1
IFS=' ' read -a INFO <<< "$MFINFO"
ORG=${INFO[0]}
FORK=${INFO[1]}
REPO=${INFO[2]}
TARG=${INFO[3]}
OLDBRANCH=${INFO[4]}
case "$#" in
0 ) BRANCH=$OLDBRANCH ;;
1 ) BRANCH=$1 ;;
* ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
esac
BRANCH=${INFO[4]}
OLDBRANCH=${INFO[5]}
set -e
# Prevent accidental loss of current changes
[[ $(git stash) != "No local "* ]] && HAS_STASH=1
echo "Fetching upstream ($ORG/$REPO)..."
git fetch upstream
echo ; echo "Bringing $TARG up to date..."
git checkout -q $TARG || git branch checkout upstream/$TARG -b $TARG && git push --set-upstream origin $TARG
git merge upstream/$TARG
git push origin
if [[ git checkout -q $TARG ]]; then
git reset --hard upstream/$TARG
git push -f origin
else
git checkout upstream/$TARG -b $TARG
git push --set-upstream origin $TARG
fi
if [[ $BRANCH != $TARG ]]; then
echo ; echo "Rebasing $BRANCH on $TARG..."
if git checkout $BRANCH; then
echo
if git rebase $TARG; then
git push -f ; echo
[[ $BRANCH != $OLDBRANCH ]] && git checkout $OLDBRANCH
git push -f
else
echo "Looks like merge conflicts. Stopping here."
echo "Looks like merge conflicts. Stopping here." ; exit
fi
else
echo "No such branch!" ; echo
git checkout $OLDBRANCH
echo "No such branch!"
fi
fi
echo
[[ $BRANCH != $OLDBRANCH ]] && git checkout $OLDBRANCH
[[ $HAS_STASH == 1 ]] && git stash pop