2016-04-18 23:18:35 -05:00
|
|
|
#!/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
|
2017-05-04 03:22:17 -05:00
|
|
|
Marlin ) TARG=bugfix-1.1.x ;;
|
2017-04-20 21:28:54 -05:00
|
|
|
MarlinDev ) TARG=dev ;;
|
|
|
|
MarlinDocumentation ) TARG=master ;;
|
2016-04-18 23:18:35 -05:00
|
|
|
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
|
|
|
|
|
2017-04-20 21:24:43 -05:00
|
|
|
if [[ $BRANCH == "(no" ]]; then
|
|
|
|
echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-18 23:18:35 -05:00
|
|
|
echo "$ORG $FORK $REPO $TARG $BRANCH"
|