You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.9 KiB
Plaintext
61 lines
1.9 KiB
Plaintext
9 years ago
|
#!/usr/bin/env bash
|
||
|
#
|
||
|
# mfinfo
|
||
|
#
|
||
8 years ago
|
# Provide the following info about the working directory:
|
||
9 years ago
|
#
|
||
|
# - Remote (upstream) Org name (MarlinFirmware)
|
||
|
# - Remote (origin) Org name (your Github username)
|
||
6 years ago
|
# - Repo Name (Marlin, MarlinDocumentation)
|
||
5 years ago
|
# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, etc.)
|
||
8 years ago
|
# - Branch Arg (the branch argument or current branch)
|
||
|
# - Current Branch
|
||
9 years ago
|
#
|
||
|
|
||
8 years ago
|
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; }
|
||
9 years ago
|
|
||
8 years ago
|
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; }
|
||
9 years ago
|
|
||
|
ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
||
8 years ago
|
[[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
|
||
9 years ago
|
|
||
|
FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
||
|
|
||
6 years ago
|
# Defaults if no arguments given
|
||
|
BRANCH=$CURR
|
||
|
INDEX=1
|
||
|
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
opt="$1" ; shift ; val="$1"
|
||
|
|
||
|
IFS='=' read -a PARTS <<<"$opt"
|
||
5 years ago
|
[[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
|
||
6 years ago
|
|
||
|
GOODVAL=1
|
||
|
if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
|
||
|
GOODVAL=0
|
||
|
val=""
|
||
|
fi
|
||
|
|
||
|
case "$opt" in
|
||
5 years ago
|
-*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;;
|
||
5 years ago
|
1|2|3) INDEX=$opt ;;
|
||
6 years ago
|
*) BRANCH="$opt" ;;
|
||
|
esac
|
||
|
|
||
|
done
|
||
|
|
||
|
case "$REPO" in
|
||
5 years ago
|
Marlin ) TARG=bugfix-1.1.x ; [[ $INDEX == 2 ]] && TARG=bugfix-2.0.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;;
|
||
6 years ago
|
MarlinDocumentation ) TARG=master ;;
|
||
9 years ago
|
esac
|
||
|
|
||
5 years ago
|
[[ $BRANCH =~ ^[123]$ ]] && USAGE=1
|
||
6 years ago
|
|
||
5 years ago
|
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1 ; }
|
||
6 years ago
|
|
||
6 years ago
|
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"
|