Browse Source

🔨 Update git helper scripts

Scott Lahteine 3 years ago
parent
commit
cac42e24a5

+ 9
- 5
buildroot/share/git/mffp View File

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 #
2
 #
3
-# mffp [1|2|3] [commit-id]
3
+# mffp [1|2] [ref]
4
 #
4
 #
5
 # Push the given commit (or HEAD) upstream immediately.
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
   MFINFO=$(mfinfo "$1") || exit 1
14
   MFINFO=$(mfinfo "$1") || exit 1
13
   REF=${2:-HEAD}
15
   REF=${2:-HEAD}
14
-else
16
+elif [[ $# == 1 ]]; then
15
   MFINFO=$(mfinfo) || exit 1
17
   MFINFO=$(mfinfo) || exit 1
16
   REF=${1:-HEAD}
18
   REF=${1:-HEAD}
19
+else
20
+  usage
17
 fi
21
 fi
18
 
22
 
19
 IFS=' ' read -a INFO <<< "$MFINFO"
23
 IFS=' ' read -a INFO <<< "$MFINFO"

+ 16
- 12
buildroot/share/git/mfinfo View File

2
 #
2
 #
3
 # mfinfo
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
 #   - Remote (upstream) Org name (MarlinFirmware)
7
 #   - Remote (upstream) Org name (MarlinFirmware)
8
 #   - Remote (origin) Org name (your Github username)
8
 #   - Remote (origin) Org name (your Github username)
9
 #   - Repo Name (Marlin, MarlinDocumentation)
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
 #   - Branch Arg (the branch argument or current branch)
11
 #   - Branch Arg (the branch argument or current branch)
12
 #   - Current Branch
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
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
19
 CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
16
 [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
20
 [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
26
 
30
 
27
 # Defaults if no arguments given
31
 # Defaults if no arguments given
28
 BRANCH=$CURR
32
 BRANCH=$CURR
29
-INDEX=1
33
+MORE=""
34
+INDEX=2
30
 
35
 
36
+# Loop through arguments
31
 while [[ $# -gt 0 ]]; do
37
 while [[ $# -gt 0 ]]; do
38
+  # Get an arg and maybe a val to go with it
32
   opt="$1" ; shift ; val="$1"
39
   opt="$1" ; shift ; val="$1"
33
 
40
 
41
+  # Split up an arg containing =
34
   IFS='=' read -a PARTS <<<"$opt"
42
   IFS='=' read -a PARTS <<<"$opt"
35
   [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
43
   [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
36
 
44
 
37
-  GOODVAL=1
38
   if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
45
   if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
39
-    GOODVAL=0
40
     val=""
46
     val=""
41
   fi
47
   fi
42
 
48
 
43
   case "$opt" in
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
          *) BRANCH="$opt" ;;
52
          *) BRANCH="$opt" ;;
47
   esac
53
   esac
48
 
54
 
49
 done
55
 done
50
 
56
 
51
 case "$REPO" in
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
   Configurations      ) TARG=import-2.0.x ;;
59
   Configurations      ) TARG=import-2.0.x ;;
54
   MarlinDocumentation ) TARG=master ;;
60
   MarlinDocumentation ) TARG=master ;;
55
   AutoBuildMarlin     ) TARG=master ;;
61
   AutoBuildMarlin     ) TARG=master ;;
56
 esac
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 View File

6
 #
6
 #
7
 
7
 
8
 usage() {
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
 [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
12
 [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
19
 # BRANCH can be given as the last argument
19
 # BRANCH can be given as the last argument
20
 case "$#" in
20
 case "$#" in
21
   1 ) case "$1" in
21
   1 ) case "$1" in
22
-        1|2|3) ;;
22
+        1|2) ;;
23
         *) BRANCH=$1 ;;
23
         *) BRANCH=$1 ;;
24
       esac
24
       esac
25
       ;;
25
       ;;
26
   2 ) case "$1" in
26
   2 ) case "$1" in
27
-        1|2|3) BRANCH=$2 ;;
27
+        1|2) BRANCH=$2 ;;
28
         *) usage ; exit 1 ;;
28
         *) usage ; exit 1 ;;
29
       esac
29
       esac
30
       ;;
30
       ;;

+ 3
- 3
buildroot/share/git/mfpr View File

1
 #!/usr/bin/env bash
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
 MFINFO=$(mfinfo "$@") || exit 1
10
 MFINFO=$(mfinfo "$@") || exit 1
11
 IFS=' ' read -a INFO <<< "$MFINFO"
11
 IFS=' ' read -a INFO <<< "$MFINFO"

+ 2
- 2
buildroot/share/git/mfqp View File

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 #
2
 #
3
-# mfqp [1|2|3]
3
+# mfqp [1|2]
4
 #
4
 #
5
 #  - git add .
5
 #  - git add .
6
 #  - git commit --amend
6
 #  - git commit --amend
24
   let IND+=1
24
   let IND+=1
25
 done
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
 [[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }
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 View File

2
 #
2
 #
3
 # mfrb
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
 MFINFO=$(mfinfo "$@") || exit 1
8
 MFINFO=$(mfinfo "$@") || exit 1
21
   let IND+=1
21
   let IND+=1
22
 done
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
 [[ $QUICK ]] || git fetch upstream
26
 [[ $QUICK ]] || git fetch upstream
27
 git rebase upstream/$TARG && git rebase -i upstream/$TARG
27
 git rebase upstream/$TARG && git rebase -i upstream/$TARG

Loading…
Cancel
Save