1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-30 15:26:18 +00:00
MarlinFirmware/buildroot/share/git/mfinfo

58 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
#
# mfinfo
#
2017-07-03 01:43:57 +00:00
# Provide the following info about the working directory:
#
# - Remote (upstream) Org name (MarlinFirmware)
# - Remote (origin) Org name (your Github username)
2017-07-03 01:43:57 +00:00
# - Repo Name (Marlin, MarlinDev, MarlinDocumentation)
2017-11-04 22:20:43 +00:00
# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, or master)
2017-07-03 01:43:57 +00:00
# - Branch Arg (the branch argument or current branch)
# - Current Branch
#
2017-11-04 22:20:43 +00:00
usage() {
echo "Usage: `basename $0` [1|2] [branch]" 1>&2
}
2018-03-02 02:40:53 +00:00
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
2017-07-03 01:43:57 +00: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; }
2017-07-03 01:43:57 +00: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; }
ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
2017-07-03 01:43:57 +00:00
[[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
case "$REPO" in
2017-11-04 22:20:43 +00:00
Marlin ) TARG=bugfix-1.1.x ;
[[ $# > 0 ]] && [[ $1 == 2 ]] && TARG=bugfix-2.0.x
;;
MarlinDocumentation ) TARG=master ;;
esac
FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
2017-11-04 22:20:43 +00:00
# BRANCH can be given as the last argument
case "$#" in
2017-07-03 01:43:57 +00:00
0 ) BRANCH=$CURR ;;
2017-11-04 22:20:43 +00:00
1 )
case "$1" in
1|2) BRANCH=$CURR ;;
*) BRANCH=$1 ;;
esac
;;
2 )
case "$1" in
1|2) BRANCH=$2 ;;
*) usage ; exit 1 ;;
esac
;;
esac
2017-07-03 01:43:57 +00:00
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"