Переглянути джерело

Update git helper scripts

Scott Lahteine 7 роки тому
джерело
коміт
ca21367dde

+ 21
- 5
buildroot/share/git/mfinfo Переглянути файл

@@ -7,11 +7,15 @@
7 7
 #   - Remote (upstream) Org name (MarlinFirmware)
8 8
 #   - Remote (origin) Org name (your Github username)
9 9
 #   - Repo Name (Marlin, MarlinDev, MarlinDocumentation)
10
-#   - PR Target branch (bugfix-2.0.x, dev, or master)
10
+#   - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, or master)
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
+
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; }
17 21
 [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
@@ -23,17 +27,29 @@ ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
23 27
 [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
24 28
 
25 29
 case "$REPO" in
26
-  Marlin              ) TARG=bugfix-2.0.x ;;
27
-  MarlinDev           ) TARG=dev ;;
30
+  Marlin              ) TARG=bugfix-1.1.x ;
31
+                        [[ $# > 0 ]] && [[ $1 == 2 ]] && TARG=bugfix-2.0.x
32
+                        ;;
28 33
   MarlinDocumentation ) TARG=master ;;
29 34
 esac
30 35
 
31 36
 FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
32 37
 
38
+# BRANCH can be given as the last argument
33 39
 case "$#" in
34 40
   0 ) BRANCH=$CURR ;;
35
-  1 ) BRANCH=$1 ;;
36
-  * ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
41
+  1 )
42
+    case "$1" in
43
+      1|2) BRANCH=$CURR ;;
44
+      *) BRANCH=$1 ;;
45
+    esac
46
+    ;;
47
+  2 )
48
+    case "$1" in
49
+      1|2) BRANCH=$2 ;;
50
+      *) usage ; exit 1 ;;
51
+    esac
52
+    ;;
37 53
 esac
38 54
 
39 55
 echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"

+ 18
- 4
buildroot/share/git/mfnew Переглянути файл

@@ -5,15 +5,29 @@
5 5
 # Create a new branch from the default target with the given name
6 6
 #
7 7
 
8
-[[ $# < 2 ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
8
+usage() {
9
+  echo "Usage: `basename $0` [1|2] [name]" 1>&2
10
+}
9 11
 
10
-MFINFO=$(mfinfo) || exit 1
12
+[[ $# < 3 ]] || { usage ; exit 1 ; }
13
+
14
+MFINFO=$(mfinfo "$@") || exit 1
11 15
 IFS=' ' read -a INFO <<< "$MFINFO"
12 16
 TARG=${INFO[3]}
17
+BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
13 18
 
19
+# BRANCH can be given as the last argument
14 20
 case "$#" in
15
-  0 ) BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S") ;;
16
-  1 ) BRANCH=$1 ;;
21
+  1 ) case "$1" in
22
+        1|2) ;;
23
+        *) BRANCH=$1 ;;
24
+      esac
25
+      ;;
26
+  2 ) case "$1" in
27
+        1|2) BRANCH=$2 ;;
28
+        *) usage ; exit 1 ;;
29
+      esac
30
+      ;;
17 31
 esac
18 32
 
19 33
 git fetch upstream

+ 6
- 7
buildroot/share/git/mfqp Переглянути файл

@@ -5,24 +5,23 @@
5 5
 # Add all changed files, commit as "patch", do `mfrb` and `git push -f`
6 6
 #
7 7
 
8
-[[ $# == 0 ]] || { echo "Usage: `basename $0`" 1>&2 ; exit 1; }
8
+[[ $# < 2 ]] || { echo "Usage: `basename $0` [1|2]" 1>&2 ; exit 1; }
9 9
 
10
-MFINFO=$(mfinfo) || exit 1
10
+MFINFO=$(mfinfo "$@") || exit 1
11 11
 IFS=' ' read -a INFO <<< "$MFINFO"
12 12
 REPO=${INFO[2]}
13 13
 TARG=${INFO[3]}
14
-BRANCH=${INFO[5]}
14
+CURR=${INFO[5]}
15 15
 
16 16
 git add .
17 17
 git commit -m "patch"
18 18
 
19
-if [[ $BRANCH == $TARG ]]; then
19
+if [[ $CURR == $TARG ]]; then
20 20
   if [[ $REPO == "MarlinDocumentation" ]]; then
21
-    git rebase -i HEAD~2
21
+    git rebase -i HEAD~2 && git push -f
22 22
   else
23 23
     echo "Don't alter the PR Target branch."; exit 1
24 24
   fi
25 25
 else
26
-  mfrb
27
-  git push -f
26
+  mfrb "$@" && git push -f
28 27
 fi

+ 5
- 5
buildroot/share/git/mfrb Переглянути файл

@@ -2,18 +2,18 @@
2 2
 #
3 3
 # mfrb
4 4
 #
5
-# Do "git rebase -i" against the "target" branch (RCBugFix or dev)
5
+# Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, or master)
6 6
 #
7 7
 
8
-[[ $# == 0 ]] || { echo "Usage: `basename $0`" 1>&2 ; exit 1; }
8
+[[ $# < 2 ]] || { echo "Usage: `basename $0` [1|2]" 1>&2 ; exit 1; }
9 9
 
10
-MFINFO=$(mfinfo) || exit 1
10
+MFINFO=$(mfinfo "$@") || exit 1
11 11
 IFS=' ' read -a INFO <<< "$MFINFO"
12 12
 TARG=${INFO[3]}
13
-BRANCH=${INFO[5]}
13
+CURR=${INFO[5]}
14 14
 
15 15
 # If the branch isn't currently the PR target
16
-if [[ $TARG != $BRANCH ]]; then
16
+if [[ $TARG != $CURR ]]; then
17 17
   git fetch upstream
18 18
   git rebase upstream/$TARG && git rebase -i upstream/$TARG
19 19
 fi

+ 7
- 17
buildroot/share/git/mfup Переглянути файл

@@ -5,10 +5,9 @@
5 5
 # - Fetch latest upstream and replace the PR Target branch with
6 6
 # - Rebase the (current or specified) branch on the PR Target
7 7
 # - Force-push the branch to 'origin'
8
-# -
9 8
 #
10 9
 
11
-[[ $# < 2 ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
10
+[[ $# < 3 ]] || { echo "Usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; }
12 11
 
13 12
 MFINFO=$(mfinfo "$@") || exit 1
14 13
 IFS=' ' read -a INFO <<< "$MFINFO"
@@ -17,7 +16,7 @@ FORK=${INFO[1]}
17 16
 REPO=${INFO[2]}
18 17
 TARG=${INFO[3]}
19 18
 BRANCH=${INFO[4]}
20
-OLDBRANCH=${INFO[5]}
19
+CURR=${INFO[5]}
21 20
 
22 21
 set -e
23 22
 
@@ -27,23 +26,14 @@ set -e
27 26
 echo "Fetching upstream ($ORG/$REPO)..."
28 27
 git fetch upstream
29 28
 
30
-echo ; echo "Bringing $TARG up to date..."
31
-if [[ ! $(git checkout -q $TARG) ]]; then
32
-  git reset --hard upstream/$TARG
33
-  git push -f origin
34
-else
35
-  git checkout upstream/$TARG -b $TARG
36
-  git push --set-upstream origin $TARG
37
-fi
38
-
39 29
 if [[ $BRANCH != $TARG ]]; then
40 30
   echo ; echo "Rebasing $BRANCH on $TARG..."
41
-  if git checkout $BRANCH; then
42
-    echo
43
-    if git rebase $TARG; then
31
+  if [[ $BRANCH == $CURR ]] || git checkout $BRANCH; then
32
+    if git rebase upstream/$TARG; then
44 33
       git push -f
45 34
     else
46
-      echo "Looks like merge conflicts. Stopping here." ; exit
35
+      echo "Looks like merge conflicts. Stopping here."
36
+      exit
47 37
     fi
48 38
   else
49 39
     echo "No such branch!"
@@ -51,6 +41,6 @@ if [[ $BRANCH != $TARG ]]; then
51 41
 fi
52 42
 
53 43
 echo
54
-[[ $BRANCH != $OLDBRANCH ]] && git checkout $OLDBRANCH
44
+[[ $BRANCH != $CURR ]] && git checkout $CURR
55 45
 
56 46
 [[ $HAS_STASH == 1 ]] && git stash pop

Завантаження…
Відмінити
Зберегти