From 60a4ca1182e6b57e0c649bdfd2d184434faf6287 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 May 2017 17:43:39 -0500 Subject: [PATCH] Better mfpub --- buildroot/share/git/mfpub | 53 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/buildroot/share/git/mfpub b/buildroot/share/git/mfpub index aa76498c0..190e47ae8 100755 --- a/buildroot/share/git/mfpub +++ b/buildroot/share/git/mfpub @@ -22,23 +22,21 @@ if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then exit fi +# Check out the named branch (or stay in current) +git checkout $BRANCH + if [[ $BRANCH == "gh-pages" ]]; then echo "Can't build from 'gh-pages.' Only the Jekyll branches (based on 'master')." - bundle exec jekyll serve --watch exit fi if [[ $BRANCH != "master" ]]; then + echo "Stashing any changes to files..." echo "Don't forget to update and push 'master'!" # GOJF Card git stash fi -# Check out the named branch (or stay in current) -git checkout $BRANCH - -echo "Generating MarlinDocumentation..." - COMMIT=$( git log --format="%H" -n 1 ) # Clean out changes and other junk in the branch @@ -48,28 +46,31 @@ git clean -d -f # Push 'master' to the fork and make a proper PR... if [[ $BRANCH == "master" ]]; then - if [[ $FORK == "MarlinFirmware" ]]; then + # Allow working directly with the main fork + echo -n "Pushing to origin/master... " + git push -f origin - # Allow working directly with the main fork - git push -f upstream + echo -n "Pushing to upstream/master... " + git push -f upstream +else + + if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then + firstpush else - - if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi - + echo -n "Pushing to origin/$BRANCH... " git push -f origin + fi - TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }') - URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" - - if [ -z "$TOOL" ]; then - echo "Can't find a tool to open the URL:" - echo $URL - else - echo "Opening a New PR Form..." - "$TOOL" "$URL" - fi + TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }') + URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" + if [ -z "$TOOL" ]; then + echo "Can't find a tool to open the URL:" + echo $URL + else + echo "Opening a New PR Form..." + "$TOOL" "$URL" fi fi @@ -78,6 +79,8 @@ fi # mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb # bundle install +echo "Generating MarlinDocumentation..." + # build the site statically and proof it bundle exec jekyll build --profile --trace --no-watch bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/" @@ -90,7 +93,7 @@ rsync -av _site/ ${TMPFOLDER}/ git reset --hard git clean -d -f -# Sync built-site with gh-pages +# Copy built-site into the gh-pages branch git checkout gh-pages rsync -av ${TMPFOLDER}/ ./ @@ -104,3 +107,7 @@ rm -rf ${TMPFOLDER} # Go back to the branch we started from git checkout $BRANCH + +if [[ $BRANCH != "master" ]]; then + git stash pop +fi