Sfoglia il codice sorgente

Update mfinfo to allow extra parameters

Scott Lahteine 5 anni fa
parent
commit
f7d96c5b28
1 ha cambiato i file con 32 aggiunte e 30 eliminazioni
  1. 32
    30
      buildroot/share/git/mfinfo

+ 32
- 30
buildroot/share/git/mfinfo Vedi File

@@ -6,17 +6,14 @@
6 6
 #
7 7
 #   - Remote (upstream) Org name (MarlinFirmware)
8 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)
9
+#   - Repo Name (Marlin, MarlinDocumentation)
10
+#   - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, etc.)
11 11
 #   - Branch Arg (the branch argument or current branch)
12 12
 #   - Current Branch
13 13
 #
14 14
 
15
-usage() {
16
-  echo "Usage: `basename $0` [1|2] [branch]" 1>&2
17
-}
18
-
19
-[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
15
+# usage() { echo "Usage: `basename $0` [1|2] [branch]" 1>&2 ; }
16
+# [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
20 17
 
21 18
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
22 19
 [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
@@ -28,30 +25,35 @@ REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
28 25
 ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
29 26
 [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
30 27
 
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 28
 FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
39 29
 
40
-# BRANCH can be given as the last argument
41
-case "$#" in
42
-  0 ) BRANCH=$CURR ;;
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
-    ;;
30
+# Defaults if no arguments given
31
+BRANCH=$CURR
32
+INDEX=1
33
+
34
+while [[ $# -gt 0 ]]; do
35
+  opt="$1" ; shift ; val="$1"
36
+
37
+  IFS='=' read -a PARTS <<<"$opt"
38
+  [[ "${PARTS[1]}" != "" ]] && { HAS_EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
39
+
40
+  GOODVAL=1
41
+  if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
42
+    GOODVAL=0
43
+    val=""
44
+  fi
45
+
46
+  case "$opt" in
47
+    -*|--*) MORE="$MORE$opt " ; [[ $HAS_EQUALS ]] && MORE="$MORE=$val" ;;
48
+       1|2) INDEX=$opt ;;
49
+         *) BRANCH="$opt" ;;
50
+  esac
51
+
52
+done
53
+
54
+case "$REPO" in
55
+  Marlin              ) TARG=bugfix-1.1.x ; [[ $INDEX == 2 ]] && TARG=bugfix-2.0.x ;;
56
+  MarlinDocumentation ) TARG=master ;;
55 57
 esac
56 58
 
57
-echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"
59
+echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"

Loading…
Annulla
Salva