2016-04-19 06:18:35 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# mfinfo
|
|
|
|
#
|
2017-07-03 03:43:57 +02:00
|
|
|
# Provide the following info about the working directory:
|
2016-04-19 06:18:35 +02:00
|
|
|
#
|
|
|
|
# - Remote (upstream) Org name (MarlinFirmware)
|
|
|
|
# - Remote (origin) Org name (your Github username)
|
2017-07-03 03:43:57 +02:00
|
|
|
# - Repo Name (Marlin, MarlinDev, MarlinDocumentation)
|
2017-07-27 10:02:53 +02:00
|
|
|
# - PR Target branch (bugfix-2.0.x, dev, or master)
|
2017-07-03 03:43:57 +02:00
|
|
|
# - Branch Arg (the branch argument or current branch)
|
|
|
|
# - Current Branch
|
2016-04-19 06:18:35 +02:00
|
|
|
#
|
|
|
|
|
2017-07-03 03:43:57 +02:00
|
|
|
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
|
|
|
|
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
|
|
|
|
[[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
|
2016-04-19 06:18:35 +02:00
|
|
|
|
2017-07-03 03:43:57 +02:00
|
|
|
REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
|
|
|
|
[[ -z $REPO ]] && { echo "`basename $0`: No 'upstream' remote found. (Did you run mfinit?)" 1>&2 ; exit 1; }
|
2016-04-19 06:18:35 +02:00
|
|
|
|
|
|
|
ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
2017-07-03 03:43:57 +02:00
|
|
|
[[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
|
2016-04-19 06:18:35 +02:00
|
|
|
|
|
|
|
case "$REPO" in
|
2017-07-27 10:02:53 +02:00
|
|
|
Marlin ) TARG=bugfix-2.0.x ;;
|
2017-04-21 04:28:54 +02:00
|
|
|
MarlinDev ) TARG=dev ;;
|
|
|
|
MarlinDocumentation ) TARG=master ;;
|
2016-04-19 06:18:35 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
|
|
|
|
|
|
|
case "$#" in
|
2017-07-03 03:43:57 +02:00
|
|
|
0 ) BRANCH=$CURR ;;
|
2016-04-19 06:18:35 +02:00
|
|
|
1 ) BRANCH=$1 ;;
|
|
|
|
* ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
2017-07-03 03:43:57 +02:00
|
|
|
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"
|