Browse Source

Update mfdoc, mfpub

Scott Lahteine 4 years ago
parent
commit
d3a8a81756
2 changed files with 32 additions and 47 deletions
  1. 2
    4
      buildroot/share/git/mfdoc
  2. 30
    43
      buildroot/share/git/mfpub

+ 2
- 4
buildroot/share/git/mfdoc View File

5
 # Start Jekyll in watch mode to work on Marlin Documentation and preview locally
5
 # Start Jekyll in watch mode to work on Marlin Documentation and preview locally
6
 #
6
 #
7
 
7
 
8
-[[ $# == 0 ]] || { echo "usage: `basename $0`" 1>&2 ; exit 1; }
8
+[[ $# == 0 ]] || { echo "Usage: `basename $0`" 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"
16
 [[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; }
16
 [[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; }
17
 
17
 
18
 opensite() {
18
 opensite() {
19
-  which xdg-open >/dev/null && TOOL=xdg-open
20
-  which gnome-open >/dev/null && TOOL=gnome-open
21
-  which open >/dev/null && TOOL=open
22
   URL="http://127.0.0.1:4000/"
19
   URL="http://127.0.0.1:4000/"
20
+  OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
23
   if [ -z "$OPEN" ]; then
21
   if [ -z "$OPEN" ]; then
24
     echo "Can't find a tool to open the URL:"
22
     echo "Can't find a tool to open the URL:"
25
     echo $URL
23
     echo $URL

+ 30
- 43
buildroot/share/git/mfpub View File

5
 # Use Jekyll to generate Marlin Documentation, which is then
5
 # Use Jekyll to generate Marlin Documentation, which is then
6
 # git-pushed to Github to publish it to the live site.
6
 # git-pushed to Github to publish it to the live site.
7
 # This publishes the current branch, and doesn't force
7
 # This publishes the current branch, and doesn't force
8
-# changes to be pushed to the 'master' branch. Be sure to push
9
-# any permanent changes to 'master'.
8
+# changes to be pushed to the 'master' branch. Be sure to
9
+# push any permanent changes to 'master'.
10
 #
10
 #
11
 
11
 
12
-[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [branch]" 1>&2 ; exit 1; }
12
+[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
13
 
13
 
14
 MFINFO=$(mfinfo "$@") || exit 1
14
 MFINFO=$(mfinfo "$@") || exit 1
15
 IFS=' ' read -a INFO <<< "$MFINFO"
15
 IFS=' ' read -a INFO <<< "$MFINFO"
18
 REPO=${INFO[2]}
18
 REPO=${INFO[2]}
19
 TARG=${INFO[3]}
19
 TARG=${INFO[3]}
20
 BRANCH=${INFO[4]}
20
 BRANCH=${INFO[4]}
21
+CURR=${INFO[5]}
21
 
22
 
22
 if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
23
 if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
23
   echo "Wrong repository."
24
   echo "Wrong repository."
30
 fi
31
 fi
31
 
32
 
32
 # Check out the named branch (or stay in current)
33
 # Check out the named branch (or stay in current)
33
-git checkout $BRANCH
34
 
34
 
35
-echo "Stashing any changes to files..."
36
-echo "Don't forget to update and push 'master'!"
37
-# GOJF Card
38
-[[ $(git stash) != "No local "* ]] && HAS_STASH=1
35
+if [[ $BRANCH != $CURR ]]; then
36
+  git checkout $BRANCH
37
+  echo "Stashing any changes to files..."
38
+  [[ $(git stash) != "No local "* ]] && HAS_STASH=1
39
+fi
39
 
40
 
40
 COMMIT=$( git log --format="%H" -n 1 )
41
 COMMIT=$( git log --format="%H" -n 1 )
41
 
42
 
42
 # Clean out changes and other junk in the branch
43
 # Clean out changes and other junk in the branch
43
 git clean -d -f
44
 git clean -d -f
44
 
45
 
46
+opensite() {
47
+  URL="$1"
48
+  OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
49
+  if [ -z "$OPEN" ]; then
50
+    echo "Can't find a tool to open the URL:"
51
+    echo $URL
52
+  else
53
+    echo "Opening the site in the browser..."
54
+    "$OPEN" "$URL"
55
+  fi
56
+}
57
+
45
 # Push 'master' to the fork and make a proper PR...
58
 # Push 'master' to the fork and make a proper PR...
46
-if [[ $BRANCH == "master" ]]; then
59
+if [[ $BRANCH == $TARG ]]; then
47
 
60
 
48
   # Don't lose upstream changes!
61
   # Don't lose upstream changes!
49
   git fetch upstream
62
   git fetch upstream
50
 
63
 
51
   # Rebase onto latest master
64
   # Rebase onto latest master
52
-  if git rebase upstream/master; then
65
+  if git rebase upstream/$TARG; then
53
 
66
 
54
     # Allow working directly with the main fork
67
     # Allow working directly with the main fork
55
     echo
68
     echo
56
-    echo -n "Pushing to origin/master... "
69
+    echo -n "Pushing to origin/$TARG... "
57
     git push -f origin
70
     git push -f origin
58
 
71
 
59
     echo
72
     echo
60
-    echo -n "Pushing to upstream/master... "
73
+    echo -n "Pushing to upstream/$TARG... "
61
     git push -f upstream
74
     git push -f upstream
62
 
75
 
63
   else
76
   else
77
     git push -f origin
90
     git push -f origin
78
   fi
91
   fi
79
 
92
 
80
-  which xdg-open >/dev/null && TOOL=xdg-open
81
-  which gnome-open >/dev/null && TOOL=gnome-open
82
-  which open >/dev/null && TOOL=open
83
-  URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
84
-
85
-  if [ -z "$OPEN" ]; then
86
-    echo "Can't find a tool to open the URL:"
87
-    echo $URL
88
-  else
89
-    echo "Opening a New PR Form..."
90
-    "$OPEN" "$URL"
91
-  fi
93
+  opensite "https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
92
 
94
 
93
 fi
95
 fi
94
 
96
 
117
 git checkout gh-pages || { echo "Something went wrong!"; exit 1; }
119
 git checkout gh-pages || { echo "Something went wrong!"; exit 1; }
118
 rsync -av ${TMPFOLDER}/ ./
120
 rsync -av ${TMPFOLDER}/ ./
119
 
121
 
120
-opensite() {
121
-  which xdg-open >/dev/null && TOOL=xdg-open
122
-  which gnome-open >/dev/null && TOOL=gnome-open
123
-  which open >/dev/null && TOOL=open
124
-  URL="http://marlinfw.org/"
125
-  if [ -z "$OPEN" ]; then
126
-    echo "Can't find a tool to open the URL:"
127
-    echo $URL
128
-  else
129
-    echo "Opening the site in the browser..."
130
-    "$OPEN" "$URL"
131
-  fi
132
-}
133
-
134
 # Commit and push the new live site directly
122
 # Commit and push the new live site directly
135
 git add --all
123
 git add --all
136
 git commit --message "Built from ${COMMIT}"
124
 git commit --message "Built from ${COMMIT}"
137
-git push upstream | {
125
+git push -f origin
126
+git push -f upstream | {
138
   while IFS= read -r line
127
   while IFS= read -r line
139
   do
128
   do
140
-    [[ $line =~ "gh-pages -> gh-pages" ]] && opensite
129
+    [[ $line =~ "gh-pages -> gh-pages" ]] && opensite "http://marlinfw.org/"
141
     echo "$line"
130
     echo "$line"
142
   done
131
   done
143
 }
132
 }
146
 rm -rf ${TMPFOLDER}
135
 rm -rf ${TMPFOLDER}
147
 
136
 
148
 # Go back to the branch we started from
137
 # Go back to the branch we started from
149
-git checkout $BRANCH
150
-
151
-[[ $HAS_STASH == 1 ]] && git stash pop
138
+[[ $BRANCH != $CURR ]] && { git checkout $BRANCH ; [[ $HAS_STASH == 1 ]] && git stash pop ; }

Loading…
Cancel
Save