|
@@ -2,15 +2,19 @@
|
2
|
2
|
#
|
3
|
3
|
# mfinfo
|
4
|
4
|
#
|
5
|
|
-# Provide the following info about the working directory:
|
|
5
|
+# Print the following info about the working copy:
|
6
|
6
|
#
|
7
|
7
|
# - Remote (upstream) Org name (MarlinFirmware)
|
8
|
8
|
# - Remote (origin) Org name (your Github username)
|
9
|
9
|
# - Repo Name (Marlin, MarlinDocumentation)
|
10
|
|
-# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, etc.)
|
|
10
|
+# - PR Target branch (e.g., bugfix-2.0.x)
|
11
|
11
|
# - Branch Arg (the branch argument or current branch)
|
12
|
12
|
# - Current Branch
|
13
|
13
|
#
|
|
14
|
+# Example output
|
|
15
|
+# > mfinfo -q ongoing
|
|
16
|
+# MarlinFirmware john.doe Marlin bugfix-2.0.x ongoing bugfix-2.0.x -q
|
|
17
|
+#
|
14
|
18
|
|
15
|
19
|
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
|
16
|
20
|
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
|
|
@@ -26,37 +30,37 @@ FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
26
|
30
|
|
27
|
31
|
# Defaults if no arguments given
|
28
|
32
|
BRANCH=$CURR
|
29
|
|
-INDEX=1
|
|
33
|
+MORE=""
|
|
34
|
+INDEX=2
|
30
|
35
|
|
|
36
|
+# Loop through arguments
|
31
|
37
|
while [[ $# -gt 0 ]]; do
|
|
38
|
+ # Get an arg and maybe a val to go with it
|
32
|
39
|
opt="$1" ; shift ; val="$1"
|
33
|
40
|
|
|
41
|
+ # Split up an arg containing =
|
34
|
42
|
IFS='=' read -a PARTS <<<"$opt"
|
35
|
43
|
[[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
|
36
|
44
|
|
37
|
|
- GOODVAL=1
|
38
|
45
|
if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
|
39
|
|
- GOODVAL=0
|
40
|
46
|
val=""
|
41
|
47
|
fi
|
42
|
48
|
|
43
|
49
|
case "$opt" in
|
44
|
|
- -*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;;
|
45
|
|
- 1|2|3) INDEX=$opt ;;
|
|
50
|
+ -*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;;
|
|
51
|
+ 1|2) INDEX=$opt ;;
|
46
|
52
|
*) BRANCH="$opt" ;;
|
47
|
53
|
esac
|
48
|
54
|
|
49
|
55
|
done
|
50
|
56
|
|
51
|
57
|
case "$REPO" in
|
52
|
|
- Marlin ) TARG=bugfix-2.0.x ; [[ $INDEX == 1 ]] && TARG=bugfix-1.1.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;;
|
|
58
|
+ Marlin ) TARG=bugfix-2.0.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;;
|
53
|
59
|
Configurations ) TARG=import-2.0.x ;;
|
54
|
60
|
MarlinDocumentation ) TARG=master ;;
|
55
|
61
|
AutoBuildMarlin ) TARG=master ;;
|
56
|
62
|
esac
|
57
|
63
|
|
58
|
|
-[[ $BRANCH =~ ^[123]$ ]] && USAGE=1
|
59
|
|
-
|
60
|
|
-[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1 ; }
|
|
64
|
+[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; }
|
61
|
65
|
|
62
|
|
-echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"
|
|
66
|
+echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE"
|