Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 90 lines (78 sloc) 2.97 KB
#!/bin/bash
set -e -f -u -o pipefail
main() {
if [[ "$#" -ne 0 ]]; then
printf "%s: no arguments accepted\\n" "$0" >&2
return 1
fi
local STANDALONE_THEME_DIR="${HOME}/src/hugo-coder"
local WEBSITE_DIR="${HOME}/src/johntobin.ie" THEME_SUBDIR="themes/hugo-coder"
readonly STANDALONE_THEME_DIR WEBSITE_DIR THEME_SUBDIR
# Update the checkout I use for development.
cd "${STANDALONE_THEME_DIR}"
git check-local-copy-is-clean --ignore-unpushed-commits
if ! git remote show | grep -q upstream; then
git remote add upstream https://github.com/luizdepra/hugo-coder
fi
# Pull upstream changes into my local copy and push to my fork on Github.
printf "*** Updating master in %s\\n" "${STANDALONE_THEME_DIR}"
git checkout master
git pull upstream master
git push
# Pull any changes made through review on github, merge upstream changes from
# master branch, and push to my fork on Github.
# If necessary: create the branch and push it to Github.
printf "*** Updating changes-for-upstream in %s\\n" "${STANDALONE_THEME_DIR}"
if ! git checkout changes-for-upstream; then
git checkout -b changes-for-upstream
git branch --set-upstream-to=origin/changes-for-upstream \
changes-for-upstream
git push
fi
git pull
git merge master
git push
# Pull any changes I have made, merge upstream changes from both master and my
# changes-for-upstream branchs, and push to Github.
printf "*** Updating my-changes in %s\\n" "${STANDALONE_THEME_DIR}"
git checkout my-changes
git pull
git merge master
git merge changes-for-upstream
git push
# Update the checkout I use when building the website.
# Check that the website repo is clean. This protects against this sequence:
# - git add foo
# - update-hugo-coder
# - ....
# - git add themes/hugo-coder
# - git commit # Commits both themes/hugo-coder and foo.
cd "${WEBSITE_DIR}"
printf "*** Checking %s is clean\\n" "${WEBSITE_DIR}"
git check-local-copy-is-clean --ignore-unpushed-commits
# Update the copy of hugo-coder that Hugo uses.
cd "${WEBSITE_DIR}/${THEME_SUBDIR}"
printf "*** Updating in %s\\n" "${WEBSITE_DIR}/${THEME_SUBDIR}"
git check-local-copy-is-clean --ignore-unpushed-commits
git checkout my-changes
git check-local-copy-is-clean --ignore-unpushed-commits
git pull
git push
# Commit the theme changes in the website repo if there were any.
cd "${WEBSITE_DIR}"
if ! git check-local-copy-is-clean --ignore-unpushed-commits 2>/dev/null; then
printf "*** Commiting changes in %s\\n" "${WEBSITE_DIR}"
git add "${THEME_SUBDIR}"
git commit -m "Updated ${THEME_SUBDIR}."
fi
printf "*** Updating in %s\\n" "${WEBSITE_DIR}"
git pull
git push
git check-local-copy-is-clean
# Check for diffs in template files that need to be copied over.
printf "*** Checking for diffs that need to be copied over in %s\\n" \
"${WEBSITE_DIR}/${THEME_SUBDIR}"
cd "${WEBSITE_DIR}/${THEME_SUBDIR}"
diff -Naur layouts/posts layouts/blog
}
main "$@"
You can’t perform that action at this time.