瀏覽代碼

🔨 Update git helper scripts

Scott Lahteine 2 年之前
父節點
當前提交
cac42e24a5
共有 6 個檔案被更改,包括 35 行新增27 行删除
  1. 9
    5
      buildroot/share/git/mffp
  2. 16
    12
      buildroot/share/git/mfinfo
  3. 3
    3
      buildroot/share/git/mfnew
  4. 3
    3
      buildroot/share/git/mfpr
  5. 2
    2
      buildroot/share/git/mfqp
  6. 2
    2
      buildroot/share/git/mfrb

+ 9
- 5
buildroot/share/git/mffp 查看文件

@@ -1,19 +1,23 @@
1 1
 #!/usr/bin/env bash
2 2
 #
3
-# mffp [1|2|3] [commit-id]
3
+# mffp [1|2] [ref]
4 4
 #
5 5
 # Push the given commit (or HEAD) upstream immediately.
6
-# By default: `git push upstream HEAD:bugfix-1.1.x`
6
+# By default: `git push upstream HEAD:bugfix-2.0.x`
7 7
 #
8 8
 
9
-[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [commit-id]" 1>&2 ; exit 1; }
9
+usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 }
10 10
 
11
-if [[ $1 == '1' || $1 == '2' || $1 == '3' ]]; then
11
+[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; }
12
+
13
+if [[ $1 == '1' || $1 == '2' ]]; then
12 14
   MFINFO=$(mfinfo "$1") || exit 1
13 15
   REF=${2:-HEAD}
14
-else
16
+elif [[ $# == 1 ]]; then
15 17
   MFINFO=$(mfinfo) || exit 1
16 18
   REF=${1:-HEAD}
19
+else
20
+  usage
17 21
 fi
18 22
 
19 23
 IFS=' ' read -a INFO <<< "$MFINFO"

+ 16
- 12
buildroot/share/git/mfinfo 查看文件

@@ -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"

+ 3
- 3
buildroot/share/git/mfnew 查看文件

@@ -6,7 +6,7 @@
6 6
 #
7 7
 
8 8
 usage() {
9
-  echo "usage: `basename $0` [1|2|3] [name]" 1>&2
9
+  echo "usage: `basename $0` [1|2] [name]" 1>&2
10 10
 }
11 11
 
12 12
 [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
@@ -19,12 +19,12 @@ BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
19 19
 # BRANCH can be given as the last argument
20 20
 case "$#" in
21 21
   1 ) case "$1" in
22
-        1|2|3) ;;
22
+        1|2) ;;
23 23
         *) BRANCH=$1 ;;
24 24
       esac
25 25
       ;;
26 26
   2 ) case "$1" in
27
-        1|2|3) BRANCH=$2 ;;
27
+        1|2) BRANCH=$2 ;;
28 28
         *) usage ; exit 1 ;;
29 29
       esac
30 30
       ;;

+ 3
- 3
buildroot/share/git/mfpr 查看文件

@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/env bash
2 2
 #
3
-# mfpr [1|2|3]
3
+# mfpr [1|2]
4 4
 #
5
-# Make a PR against bugfix-1.1.x or bugfix-2.0.x
5
+# Make a PR targeted to MarlinFirmware/[repo]
6 6
 #
7 7
 
8
-[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1; }
8
+[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; }
9 9
 
10 10
 MFINFO=$(mfinfo "$@") || exit 1
11 11
 IFS=' ' read -a INFO <<< "$MFINFO"

+ 2
- 2
buildroot/share/git/mfqp 查看文件

@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/env bash
2 2
 #
3
-# mfqp [1|2|3]
3
+# mfqp [1|2]
4 4
 #
5 5
 #  - git add .
6 6
 #  - git commit --amend
@@ -24,7 +24,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
24 24
   let IND+=1
25 25
 done
26 26
 
27
-[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
27
+[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
28 28
 
29 29
 [[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }
30 30
 

+ 2
- 2
buildroot/share/git/mfrb 查看文件

@@ -2,7 +2,7 @@
2 2
 #
3 3
 # mfrb
4 4
 #
5
-# Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, or master)
5
+# Do "git rebase -i" against the repo's "target" branch
6 6
 #
7 7
 
8 8
 MFINFO=$(mfinfo "$@") || exit 1
@@ -21,7 +21,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
21 21
   let IND+=1
22 22
 done
23 23
 
24
-[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
24
+[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
25 25
 
26 26
 [[ $QUICK ]] || git fetch upstream
27 27
 git rebase upstream/$TARG && git rebase -i upstream/$TARG

Loading…
取消
儲存