Bladeren bron

Update git helper scripts

Scott Lahteine 6 jaren geleden
bovenliggende
commit
9bd230cf64
5 gewijzigde bestanden met toevoegingen van 57 en 38 verwijderingen
  1. 21
    5
      buildroot/share/git/mfinfo
  2. 18
    4
      buildroot/share/git/mfnew
  3. 6
    7
      buildroot/share/git/mfqp
  4. 5
    5
      buildroot/share/git/mfrb
  5. 7
    17
      buildroot/share/git/mfup

+ 21
- 5
buildroot/share/git/mfinfo Bestand weergeven

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, MarlinDev, MarlinDocumentation)
9
 #   - Repo Name (Marlin, MarlinDev, MarlinDocumentation)
10
-#   - PR Target branch (bugfix-1.1.x, dev, or master)
10
+#   - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, or master)
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
 
14
 
15
+usage() {
16
+  echo "Usage: `basename $0` [1|2] [branch]" 1>&2
17
+}
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; }
17
 [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
21
 [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
23
 [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
27
 [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
24
 
28
 
25
 case "$REPO" in
29
 case "$REPO" in
26
-  Marlin              ) TARG=bugfix-1.1.x ;;
27
-  MarlinDev           ) TARG=dev ;;
30
+  Marlin              ) TARG=bugfix-1.1.x ;
31
+                        [[ $# > 0 ]] && [[ $1 == 2 ]] && TARG=bugfix-2.0.x
32
+                        ;;
28
   MarlinDocumentation ) TARG=master ;;
33
   MarlinDocumentation ) TARG=master ;;
29
 esac
34
 esac
30
 
35
 
31
 FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
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
 case "$#" in
39
 case "$#" in
34
   0 ) BRANCH=$CURR ;;
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
 esac
53
 esac
38
 
54
 
39
 echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"
55
 echo "$ORG $FORK $REPO $TARG $BRANCH $CURR"

+ 18
- 4
buildroot/share/git/mfnew Bestand weergeven

5
 # Create a new branch from the default target with the given name
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
 IFS=' ' read -a INFO <<< "$MFINFO"
15
 IFS=' ' read -a INFO <<< "$MFINFO"
12
 TARG=${INFO[3]}
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
 case "$#" in
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
 esac
31
 esac
18
 
32
 
19
 git fetch upstream
33
 git fetch upstream

+ 6
- 7
buildroot/share/git/mfqp Bestand weergeven

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

+ 5
- 5
buildroot/share/git/mfrb Bestand weergeven

2
 #
2
 #
3
 # mfrb
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
 IFS=' ' read -a INFO <<< "$MFINFO"
11
 IFS=' ' read -a INFO <<< "$MFINFO"
12
 TARG=${INFO[3]}
12
 TARG=${INFO[3]}
13
-BRANCH=${INFO[5]}
13
+CURR=${INFO[5]}
14
 
14
 
15
 # If the branch isn't currently the PR target
15
 # If the branch isn't currently the PR target
16
-if [[ $TARG != $BRANCH ]]; then
16
+if [[ $TARG != $CURR ]]; then
17
   git fetch upstream
17
   git fetch upstream
18
   git rebase upstream/$TARG && git rebase -i upstream/$TARG
18
   git rebase upstream/$TARG && git rebase -i upstream/$TARG
19
 fi
19
 fi

+ 7
- 17
buildroot/share/git/mfup Bestand weergeven

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

Laden…
Annuleren
Opslaan