Browse Source

Merge pull request #6406 from thinkyhead/test_remote

Refresh Marlin git helper scripts
Scott Lahteine 7 years ago
parent
commit
e66d9f1313

+ 24
- 0
buildroot/share/git/mfadd View File

@@ -0,0 +1,24 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfadd
4
+#
5
+# Add a remote and fetch it
6
+#
7
+
8
+MFINFO=$(mfinfo) || exit
9
+
10
+IFS=' ' read -a INFO <<< "$MFINFO"
11
+
12
+REPO=${INFO[2]}
13
+OLDBRANCH=${INFO[4]}
14
+
15
+case "$#" in
16
+  1 ) USER=$1 ;;
17
+  * ) echo "Usage: `basename $0` [user]" 1>&2 ; exit 1 ;;
18
+esac
19
+
20
+set -e
21
+
22
+echo "Adding and fetching $USER..."
23
+
24
+git remote add -f "$USER" "git@github.com:$USER/$REPO.git"

+ 48
- 0
buildroot/share/git/mfdoc View File

@@ -0,0 +1,48 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfdoc
4
+#
5
+# Start Jekyll in watch mode to work on Marlin Documentation and preview locally
6
+#
7
+
8
+MFINFO=$(mfinfo "$@") || exit
9
+IFS=' ' read -a INFO <<< "$MFINFO"
10
+ORG=${INFO[0]}
11
+REPO=${INFO[2]}
12
+BRANCH=${INFO[4]}
13
+
14
+if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
15
+  echo "Wrong repository."
16
+  exit
17
+fi
18
+
19
+if [[ $BRANCH != "master" ]]; then
20
+  echo "Stashing changes and changing to master."
21
+  git stash
22
+  git checkout master
23
+fi
24
+
25
+opensite() {
26
+  TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
27
+  URL="http://127.0.0.1:4000/"
28
+  if [ -z "$TOOL" ]; then
29
+    echo "Can't find a tool to open the URL:"
30
+    echo $URL
31
+  else
32
+    echo "Opening preview site in the browser..."
33
+    "$TOOL" "$URL"
34
+  fi
35
+}
36
+
37
+echo "Previewing MarlinDocumentation..."
38
+
39
+# wait to open the url for about 8s
40
+( sleep 8; opensite ) &
41
+
42
+bundle exec jekyll serve --watch --incremental
43
+
44
+if [[ $BRANCH != "master" ]]; then
45
+  echo "Restoring branch '$BRANCH'"
46
+  git checkout $BRANCH
47
+  git stash pop
48
+fi

+ 7
- 2
buildroot/share/git/mfinfo View File

@@ -25,8 +25,9 @@ if [[ $ORG != MarlinFirmware ]]; then
25 25
 fi
26 26
 
27 27
 case "$REPO" in
28
-  Marlin    ) TARG=RCBugFix ;;
29
-  MarlinDev ) TARG=dev ;;
28
+  Marlin              ) TARG=RCBugFix ;;
29
+  MarlinDev           ) TARG=dev ;;
30
+  MarlinDocumentation ) TARG=master ;;
30 31
 esac
31 32
 
32 33
 FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
@@ -37,4 +38,8 @@ case "$#" in
37 38
   * ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
38 39
 esac
39 40
 
41
+if [[ $BRANCH == "(no" ]]; then
42
+  echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1
43
+fi
44
+
40 45
 echo "$ORG $FORK $REPO $TARG $BRANCH"

+ 10
- 2
buildroot/share/git/mfinit View File

@@ -2,7 +2,15 @@
2 2
 #
3 3
 # mfinit
4 4
 #
5
-# Create the upstream repository for Marlin
5
+# Create the upstream remote for a forked repository
6 6
 #
7 7
 
8
-git remote add upstream git@github.com:MarlinFirmware/Marlin.git
8
+REPO=$(git remote get-url origin 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
9
+
10
+if [[ -z $REPO ]]; then
11
+  echo "`basename $0`: No 'origin' remote found." 1>&2 ; exit 1
12
+fi
13
+
14
+git remote add upstream "git@github.com:MarlinFirmware/$REPO.git"
15
+
16
+git fetch upstream

+ 2
- 7
buildroot/share/git/mfnew View File

@@ -2,20 +2,15 @@
2 2
 #
3 3
 # mfnew
4 4
 #
5
-# Create a new branch based on RCBugFix or dev a given branch name
5
+# Create a new branch from the default target with the given name
6 6
 #
7 7
 
8 8
 MFINFO=$(mfinfo) || exit
9 9
 IFS=' ' read -a INFO <<< "$MFINFO"
10 10
 TARG=${INFO[3]}
11 11
 
12
-if [[ ${INFO[4]} == "(no" ]]; then
13
-  echo "Branch is unavailable!"
14
-  exit 1
15
-fi
16
-
17 12
 case "$#" in
18
-  0 ) BRANCH=pr_for_$TARG-$(date +"%G-%d-%m|%H:%M:%S") ;;
13
+  0 ) BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S") ;;
19 14
   1 ) BRANCH=$1 ;;
20 15
   * ) echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1 ;;
21 16
 esac

+ 0
- 5
buildroot/share/git/mfpr View File

@@ -15,11 +15,6 @@ REPO=${INFO[2]}
15 15
 TARG=${INFO[3]}
16 16
 BRANCH=${INFO[4]}
17 17
 
18
-if [[ $BRANCH == "(no" ]]; then
19
-  echo "Git is busy with merge, rebase, etc."
20
-  exit 1
21
-fi
22
-
23 18
 if [[ ! -z "$1" ]]; then { BRANCH=$1 ; git checkout $1 || exit 1; } fi
24 19
 
25 20
 if [[ $BRANCH == $TARG ]]; then

+ 7
- 2
buildroot/share/git/mfprune View File

@@ -6,6 +6,11 @@
6 6
 # Great way to clean up your branches after messing around a lot
7 7
 #
8 8
 
9
+echo "Fetching latest upstream and origin..."
10
+git fetch upstream
11
+git fetch origin
12
+echo
13
+
9 14
 echo "Pruning Merged Branches..."
10 15
 git branch --merged | egrep -v "^\*|RC|RCBugFix|dev" | xargs -n 1 git branch -d
11 16
 echo
@@ -14,9 +19,9 @@ echo "Pruning Remotely-deleted Branches..."
14 19
 git branch -vv | egrep -v "^\*|RC|RCBugFix|dev" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D
15 20
 echo
16 21
 
17
-echo "You may want to remove these remote tracking references..."
22
+echo "You may want to remove (or checkout) these refs..."
18 23
 comm -23 \
19 24
   <(git branch --all | sed 's/^[\* ] //' | grep origin/ | grep -v "\->" | awk '{ print $1; }' | sed 's/remotes\/origin\///') \
20 25
   <(git branch --all | sed 's/^[\* ] //' | grep -v remotes/ | awk '{ print $1; }') \
21
-  | awk '{ print "git branch -d -r origin/" $1; }'
26
+  | awk '{ print "git branch -d -r origin/" $1; print "git checkout origin/" $1 " -b " $1; }'
22 27
 echo

+ 90
- 0
buildroot/share/git/mfpub View File

@@ -0,0 +1,90 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfpub
4
+#
5
+# Use Jekyll to publish Marlin Documentation to the HTML site
6
+#
7
+
8
+MFINFO=$(mfinfo "$@") || exit
9
+IFS=' ' read -a INFO <<< "$MFINFO"
10
+ORG=${INFO[0]}
11
+FORK=${INFO[1]}
12
+REPO=${INFO[2]}
13
+TARG=${INFO[3]}
14
+BRANCH=${INFO[4]}
15
+
16
+if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
17
+  echo "Wrong repository."
18
+  exit
19
+fi
20
+
21
+if [[ $BRANCH == "gh-pages" ]]; then
22
+  echo "Can't build from 'gh-pages.' Only the Jekyll branches."
23
+  bundle exec jekyll serve --watch
24
+  exit
25
+fi
26
+
27
+if [[ $BRANCH != "master" ]]; then
28
+  echo "Don't forget to update and push 'master'!"
29
+fi
30
+
31
+git checkout $BRANCH
32
+
33
+echo "Generating MarlinDocumentation..."
34
+
35
+# GOJF Card
36
+git stash
37
+
38
+TMPFOLDER=$( mktemp -d )
39
+COMMIT=$( git log --format="%H" -n 1 )
40
+
41
+# Clean out changes and other junk in the branch
42
+git reset --hard
43
+git clean -d -f
44
+
45
+# Push 'master' to the fork and make a proper PR...
46
+if [[ $BRANCH == "master" ]]; then
47
+
48
+  if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi
49
+
50
+  git push -f origin
51
+
52
+  TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
53
+  URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
54
+
55
+  if [ -z "$TOOL" ]; then
56
+    echo "Can't find a tool to open the URL:"
57
+    echo $URL
58
+  else
59
+    echo "Opening a New PR Form..."
60
+    "$TOOL" "$URL"
61
+  fi
62
+
63
+fi
64
+
65
+# Uncomment to compress the final html files
66
+# mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb
67
+# bundle install
68
+
69
+bundle exec jekyll build --profile --trace --no-watch
70
+bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/"
71
+
72
+rsync -av _site/ ${TMPFOLDER}/
73
+
74
+# Clean out changes and other junk in the branch
75
+git reset --hard
76
+git clean -d -f
77
+
78
+# Sync built-site with gh-pages
79
+git checkout gh-pages
80
+rsync -av ${TMPFOLDER}/ ./
81
+
82
+# Commit and push the new live site directly
83
+git add --all
84
+git commit --message "Built from ${COMMIT}"
85
+git push upstream
86
+
87
+rm -rf ${TMPFOLDER}
88
+
89
+# Go back to the branch we started from
90
+git checkout $BRANCH

+ 19
- 0
buildroot/share/git/mfqp View File

@@ -0,0 +1,19 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfqp
4
+#
5
+# Add all changed files, commit as "patch", do `mfrb` and `git push -f`
6
+#
7
+
8
+MFINFO=$(mfinfo) || exit
9
+IFS=' ' read -a INFO <<< "$MFINFO"
10
+
11
+case "$#" in
12
+  0 ) ;;
13
+  * ) echo "Usage: `basename $0`" 1>&2 ; exit 1 ;;
14
+esac
15
+
16
+git add * .travis.yml
17
+git commit -m "patch"
18
+mfrb
19
+git push -f

+ 0
- 5
buildroot/share/git/mfrb View File

@@ -8,11 +8,6 @@
8 8
 MFINFO=$(mfinfo) || exit
9 9
 IFS=' ' read -a INFO <<< "$MFINFO"
10 10
 
11
-if [[ ${INFO[4]} == "(no" ]]; then
12
-  echo "Branch is unavailable!"
13
-  exit 1
14
-fi
15
-
16 11
 case "$#" in
17 12
   0 ) ;;
18 13
   * ) echo "Usage: `basename $0`" 1>&2 ; exit 1 ;;

+ 0
- 5
buildroot/share/git/mfup View File

@@ -15,11 +15,6 @@ REPO=${INFO[2]}
15 15
 TARG=${INFO[3]}
16 16
 OLDBRANCH=${INFO[4]}
17 17
 
18
-if [[ $OLDBRANCH == "(no" ]]; then
19
-  echo "Branch is unavailable!"
20
-  exit 1
21
-fi
22
-
23 18
 case "$#" in
24 19
   0 ) BRANCH=$OLDBRANCH ;;
25 20
   1 ) BRANCH=$1 ;;

Loading…
Cancel
Save