瀏覽代碼

Add --quick option to mfqp, add BRANCH check to mfinfo

Scott Lahteine 5 年之前
父節點
當前提交
6fe39e6117
共有 2 個檔案被更改,包括 20 行新增6 行删除
  1. 4
    3
      buildroot/share/git/mfinfo
  2. 16
    3
      buildroot/share/git/mfqp

+ 4
- 3
buildroot/share/git/mfinfo 查看文件

@@ -12,9 +12,6 @@
12 12
 #   - Current Branch
13 13
 #
14 14
 
15
-# usage() { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; }
16
-# [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
17
-
18 15
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
19 16
 [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
20 17
 [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
@@ -56,4 +53,8 @@ case "$REPO" in
56 53
   MarlinDocumentation ) TARG=master ;;
57 54
 esac
58 55
 
56
+[[ $BRANCH =~ ^[0-9]$ ]] && USAGE=1
57
+
58
+[[ $USAGE ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; }
59
+
59 60
 echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"

+ 16
- 3
buildroot/share/git/mfqp 查看文件

@@ -5,14 +5,27 @@
5 5
 # Add all changed files, commit as "patch", do `mfrb` and `git push -f`
6 6
 #
7 7
 
8
-[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1; }
9
-
10 8
 MFINFO=$(mfinfo "$@") || exit 1
11 9
 IFS=' ' read -a INFO <<< "$MFINFO"
12 10
 REPO=${INFO[2]}
13 11
 TARG=${INFO[3]}
14 12
 CURR=${INFO[5]}
15 13
 
14
+IND=6
15
+while [ $IND -lt ${#INFO[@]} ]; do
16
+  ARG=${INFO[$IND]}
17
+  case "$ARG" in
18
+    -q|--quick ) QUICK="-q" ;;
19
+     -h|--help ) USAGE=1 ;;
20
+             * ) USAGE=1 ; echo "unknown option: $ARG" ;;
21
+  esac
22
+  let IND+=1
23
+done
24
+
25
+[[ ${INFO[4]} =~ [0-9] ]] && USAGE=1
26
+
27
+[[ $USAGE ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
28
+
16 29
 git add .
17 30
 git commit -m "patch"
18 31
 
@@ -23,5 +36,5 @@ if [[ $CURR == $TARG ]]; then
23 36
     echo "Don't alter the PR Target branch."; exit 1
24 37
   fi
25 38
 else
26
-  mfrb "$@" && git push -f
39
+  mfrb $QUICK "$@" && git push -f
27 40
 fi

Loading…
取消
儲存