Update mfdoc, mfpub

This commit is contained in:
Scott Lahteine 2020-01-21 05:21:23 -06:00
parent b7f86bffd5
commit d3a8a81756
2 changed files with 32 additions and 47 deletions

View File

@ -5,7 +5,7 @@
# Start Jekyll in watch mode to work on Marlin Documentation and preview locally # Start Jekyll in watch mode to work on Marlin Documentation and preview locally
# #
[[ $# == 0 ]] || { echo "usage: `basename $0`" 1>&2 ; exit 1; } [[ $# == 0 ]] || { echo "Usage: `basename $0`" 1>&2 ; exit 1; }
MFINFO=$(mfinfo "$@") || exit 1 MFINFO=$(mfinfo "$@") || exit 1
IFS=' ' read -a INFO <<< "$MFINFO" IFS=' ' read -a INFO <<< "$MFINFO"
@ -16,10 +16,8 @@ BRANCH=${INFO[5]}
[[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; } [[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; }
opensite() { opensite() {
which xdg-open >/dev/null && TOOL=xdg-open
which gnome-open >/dev/null && TOOL=gnome-open
which open >/dev/null && TOOL=open
URL="http://127.0.0.1:4000/" URL="http://127.0.0.1:4000/"
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
if [ -z "$OPEN" ]; then if [ -z "$OPEN" ]; then
echo "Can't find a tool to open the URL:" echo "Can't find a tool to open the URL:"
echo $URL echo $URL

View File

@ -5,11 +5,11 @@
# Use Jekyll to generate Marlin Documentation, which is then # Use Jekyll to generate Marlin Documentation, which is then
# git-pushed to Github to publish it to the live site. # git-pushed to Github to publish it to the live site.
# This publishes the current branch, and doesn't force # This publishes the current branch, and doesn't force
# changes to be pushed to the 'master' branch. Be sure to push # changes to be pushed to the 'master' branch. Be sure to
# any permanent changes to 'master'. # push any permanent changes to 'master'.
# #
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [branch]" 1>&2 ; exit 1; } [[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "Usage: `basename $0` [branch]" 1>&2 ; exit 1; }
MFINFO=$(mfinfo "$@") || exit 1 MFINFO=$(mfinfo "$@") || exit 1
IFS=' ' read -a INFO <<< "$MFINFO" IFS=' ' read -a INFO <<< "$MFINFO"
@ -18,6 +18,7 @@ FORK=${INFO[1]}
REPO=${INFO[2]} REPO=${INFO[2]}
TARG=${INFO[3]} TARG=${INFO[3]}
BRANCH=${INFO[4]} BRANCH=${INFO[4]}
CURR=${INFO[5]}
if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
echo "Wrong repository." echo "Wrong repository."
@ -30,34 +31,46 @@ if [[ $BRANCH == "gh-pages" ]]; then
fi fi
# Check out the named branch (or stay in current) # Check out the named branch (or stay in current)
git checkout $BRANCH
if [[ $BRANCH != $CURR ]]; then
git checkout $BRANCH
echo "Stashing any changes to files..." echo "Stashing any changes to files..."
echo "Don't forget to update and push 'master'!"
# GOJF Card
[[ $(git stash) != "No local "* ]] && HAS_STASH=1 [[ $(git stash) != "No local "* ]] && HAS_STASH=1
fi
COMMIT=$( git log --format="%H" -n 1 ) COMMIT=$( git log --format="%H" -n 1 )
# Clean out changes and other junk in the branch # Clean out changes and other junk in the branch
git clean -d -f git clean -d -f
opensite() {
URL="$1"
OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
if [ -z "$OPEN" ]; then
echo "Can't find a tool to open the URL:"
echo $URL
else
echo "Opening the site in the browser..."
"$OPEN" "$URL"
fi
}
# Push 'master' to the fork and make a proper PR... # Push 'master' to the fork and make a proper PR...
if [[ $BRANCH == "master" ]]; then if [[ $BRANCH == $TARG ]]; then
# Don't lose upstream changes! # Don't lose upstream changes!
git fetch upstream git fetch upstream
# Rebase onto latest master # Rebase onto latest master
if git rebase upstream/master; then if git rebase upstream/$TARG; then
# Allow working directly with the main fork # Allow working directly with the main fork
echo echo
echo -n "Pushing to origin/master... " echo -n "Pushing to origin/$TARG... "
git push -f origin git push -f origin
echo echo
echo -n "Pushing to upstream/master... " echo -n "Pushing to upstream/$TARG... "
git push -f upstream git push -f upstream
else else
@ -77,18 +90,7 @@ else
git push -f origin git push -f origin
fi fi
which xdg-open >/dev/null && TOOL=xdg-open opensite "https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
which gnome-open >/dev/null && TOOL=gnome-open
which open >/dev/null && TOOL=open
URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
if [ -z "$OPEN" ]; then
echo "Can't find a tool to open the URL:"
echo $URL
else
echo "Opening a New PR Form..."
"$OPEN" "$URL"
fi
fi fi
@ -117,27 +119,14 @@ git clean -d -f
git checkout gh-pages || { echo "Something went wrong!"; exit 1; } git checkout gh-pages || { echo "Something went wrong!"; exit 1; }
rsync -av ${TMPFOLDER}/ ./ rsync -av ${TMPFOLDER}/ ./
opensite() {
which xdg-open >/dev/null && TOOL=xdg-open
which gnome-open >/dev/null && TOOL=gnome-open
which open >/dev/null && TOOL=open
URL="http://marlinfw.org/"
if [ -z "$OPEN" ]; then
echo "Can't find a tool to open the URL:"
echo $URL
else
echo "Opening the site in the browser..."
"$OPEN" "$URL"
fi
}
# Commit and push the new live site directly # Commit and push the new live site directly
git add --all git add --all
git commit --message "Built from ${COMMIT}" git commit --message "Built from ${COMMIT}"
git push upstream | { git push -f origin
git push -f upstream | {
while IFS= read -r line while IFS= read -r line
do do
[[ $line =~ "gh-pages -> gh-pages" ]] && opensite [[ $line =~ "gh-pages -> gh-pages" ]] && opensite "http://marlinfw.org/"
echo "$line" echo "$line"
done done
} }
@ -146,6 +135,4 @@ git push upstream | {
rm -rf ${TMPFOLDER} rm -rf ${TMPFOLDER}
# Go back to the branch we started from # Go back to the branch we started from
git checkout $BRANCH [[ $BRANCH != $CURR ]] && { git checkout $BRANCH ; [[ $HAS_STASH == 1 ]] && git stash pop ; }
[[ $HAS_STASH == 1 ]] && git stash pop