parent
09c6323b68
commit
9a12054e0e
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
git push --set-upstream origin `git branch | grep \* | sed 's/\* //g'`
|
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfinfo
|
||||||
|
#
|
||||||
|
# Get the following helpful git info about the working directory:
|
||||||
|
#
|
||||||
|
# - Remote (upstream) Org name (MarlinFirmware)
|
||||||
|
# - Remote (origin) Org name (your Github username)
|
||||||
|
# - Repo Name (Marlin or MarlinDev)
|
||||||
|
# - Marlin Target branch (RCBugFix or dev)
|
||||||
|
# - Branch Name (the current branch or the one that was passed)
|
||||||
|
#
|
||||||
|
|
||||||
|
REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
|
||||||
|
|
||||||
|
if [[ -z $REPO ]]; then
|
||||||
|
echo "`basename $0`: No 'upstream' remote found." 1>&2 ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
||||||
|
|
||||||
|
if [[ $ORG != MarlinFirmware ]]; then
|
||||||
|
echo "`basename $0`: Not a Marlin repository."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$REPO" in
|
||||||
|
Marlin ) TARG=RCBugFix ;;
|
||||||
|
MarlinDev ) TARG=dev ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
||||||
|
|
||||||
|
case "$#" in
|
||||||
|
0 ) BRANCH=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') ;;
|
||||||
|
1 ) BRANCH=$1 ;;
|
||||||
|
* ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$ORG $FORK $REPO $TARG $BRANCH"
|
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfnew
|
||||||
|
#
|
||||||
|
# Create a new branch based on RCBugFix or dev a given branch name
|
||||||
|
#
|
||||||
|
|
||||||
|
MFINFO=$(mfinfo) || exit
|
||||||
|
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||||
|
TARG=${INFO[3]}
|
||||||
|
|
||||||
|
if [[ ${INFO[4]} == "(no" ]]; then
|
||||||
|
echo "Branch is unavailable!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$#" in
|
||||||
|
0 ) BRANCH=pr_for_$TARG-$(date +"%G-%d-%m|%H:%M:%S") ;;
|
||||||
|
1 ) BRANCH=$1 ;;
|
||||||
|
* ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
git checkout $TARG -b $BRANCH
|
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfpr
|
||||||
|
#
|
||||||
|
# Make a PR of the current branch against RCBugFix or dev
|
||||||
|
#
|
||||||
|
|
||||||
|
MFINFO=$(mfinfo "$@") || exit
|
||||||
|
|
||||||
|
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||||
|
|
||||||
|
ORG=${INFO[0]}
|
||||||
|
FORK=${INFO[1]}
|
||||||
|
REPO=${INFO[2]}
|
||||||
|
TARG=${INFO[3]}
|
||||||
|
BRANCH=${INFO[4]}
|
||||||
|
|
||||||
|
if [[ $BRANCH == "(no" ]]; then
|
||||||
|
echo "Git is busy with merge, rebase, etc."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z "$1" ]]; then { BRANCH=$1 ; git checkout $1 || exit 1; } fi
|
||||||
|
|
||||||
|
if [[ $BRANCH == $TARG ]]; then
|
||||||
|
echo "Can't make a PR from $BRANCH" ; exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
|
||||||
|
|
||||||
|
TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
|
||||||
|
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
|
||||||
|
|
||||||
|
if [ -z "$TOOL" ]; then
|
||||||
|
echo "Can't find a tool to open the URL:"
|
||||||
|
echo $URL
|
||||||
|
else
|
||||||
|
echo "Opening a New PR Form..."
|
||||||
|
"$TOOL" "$URL"
|
||||||
|
fi
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfprune
|
||||||
|
#
|
||||||
|
# Prune all your merged branches and any branches whose remotes are gone
|
||||||
|
# Great way to clean up your branches after messing around a lot
|
||||||
|
#
|
||||||
|
|
||||||
|
echo "Pruning Merged Branches..."
|
||||||
|
git branch --merged | egrep -v "^\*|RC|RCBugFix|dev" | xargs -n 1 git branch -d
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Pruning Remotely-deleted Branches..."
|
||||||
|
git branch -vv | egrep -v "^\*|RC|RCBugFix|dev" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "You may want to remove these remote tracking references..."
|
||||||
|
comm -23 \
|
||||||
|
<(git branch --all | sed 's/^[\* ] //' | grep origin/ | grep -v "\->" | awk '{ print $1; }' | sed 's/remotes\/origin\///') \
|
||||||
|
<(git branch --all | sed 's/^[\* ] //' | grep -v remotes/ | awk '{ print $1; }') \
|
||||||
|
| awk '{ print "git branch -d -r origin/" $1; }'
|
||||||
|
echo
|
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfrb
|
||||||
|
#
|
||||||
|
# Do "git rebase -i" against the "target" branch (RCBugFix or dev)
|
||||||
|
#
|
||||||
|
|
||||||
|
MFINFO=$(mfinfo) || exit
|
||||||
|
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||||
|
|
||||||
|
if [[ ${INFO[4]} == "(no" ]]; then
|
||||||
|
echo "Branch is unavailable!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$#" in
|
||||||
|
0 ) ;;
|
||||||
|
* ) echo "Usage: `basename $0`" 1>&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
git rebase -i ${INFO[3]}
|
@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# mfup
|
||||||
|
#
|
||||||
|
# Fetch and merge upstream changes, optionally with a branch
|
||||||
|
#
|
||||||
|
|
||||||
|
MFINFO=$(mfinfo) || exit
|
||||||
|
|
||||||
|
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||||
|
|
||||||
|
ORG=${INFO[0]}
|
||||||
|
FORK=${INFO[1]}
|
||||||
|
REPO=${INFO[2]}
|
||||||
|
TARG=${INFO[3]}
|
||||||
|
OLDBRANCH=${INFO[4]}
|
||||||
|
|
||||||
|
if [[ $OLDBRANCH == "(no" ]]; then
|
||||||
|
echo "Branch is unavailable!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$#" in
|
||||||
|
0 ) BRANCH=$OLDBRANCH ;;
|
||||||
|
1 ) BRANCH=$1 ;;
|
||||||
|
* ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
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 [[ $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
|
||||||
|
else
|
||||||
|
echo "Looks like merge conflicts. Stopping here."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No such branch!" ; echo
|
||||||
|
git checkout $OLDBRANCH
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in new issue