Subversion Repositories MK-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
#!/usr/bin/env bash
2
#
3
# mfinfo
4
#
5
# Provide the following info about the working directory:
6
#
7
#   - Remote (upstream) Org name (MarlinFirmware)
8
#   - Remote (origin) Org name (your Github username)
9
#   - Repo Name (Marlin, MarlinDev, MarlinDocumentation)
10
#   - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, or master)
11
#   - Branch Arg (the branch argument or current branch)
12
#   - Current Branch
13
#
14
 
15
usage() {
16
  echo "Usage: `basename $0` [1|2] [branch]" 1>&2
17
}
18
 
19
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
20
 
21
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
22
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
23
[[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
24
 
25
REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
26
[[ -z $REPO ]] && { echo "`basename $0`: No 'upstream' remote found. (Did you run mfinit?)" 1>&2 ; exit 1; }
27
 
28
ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
29
[[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
30
 
31
case "$REPO" in
32
  Marlin              ) TARG=bugfix-1.1.x ;
33
                        [[ $# > 0 ]] && [[ $1 == 2 ]] && TARG=bugfix-2.0.x
34
                        ;;
35
  MarlinDocumentation ) TARG=master ;;
36
esac
37
 
38
FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
39
 
40
# BRANCH can be given as the last argument
41
case "$#" in
42
 
43
  1 )
44
    case "$1" in
45
      1|2) BRANCH=$CURR ;;
46
      *) BRANCH=$1 ;;
47
    esac
48
    ;;
49
  2 )
50
    case "$1" in
51
      1|2) BRANCH=$2 ;;
52
      *) usage ; exit 1 ;;
53
    esac
54
    ;;
55
esac
56
 
57
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"