commit 49220a0b45afab4062747f1e117f0631fc45d13e parent 92b7b08ebc291e3d4123171b674c051a5d1b36ca Author: Chris Bracken <chris@bracken.jp> Date: Wed, 10 Apr 2019 10:05:52 -0700 Notify when no diffs to publish Diffstat:
M | publish.sh | | | 23 | ++++++++++++++--------- |
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/publish.sh b/publish.sh @@ -3,7 +3,7 @@ PUBLISH_REPO=git@github.com:cbracken/cbracken.github.io.git if ! git diff-index --quiet HEAD --; then - echo >&2 "Git diffs found. Commit changes before publishing. Aborting." + echo >&2 "Not all diffs have been committed. Aborting." exit 1 fi @@ -21,14 +21,19 @@ git clone $PUBLISH_REPO public hugo || { echo >&2 "hugo build failed. Aborting."; exit 1; } # Check diffs and publish. -echo "Build succeeded. Displaying diffs:" -git -C public diff -read -p "Commit and publish? " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]]; then - git -C public add . - git -C public commit -m "Publish site" - git -C public push origin master +echo "Build succeeded. Checking diffs..." +git -C public status +if git -C public diff-index --quiet HEAD --; then + echo >&2 "No changes to published site." +else + git -C public diff + read -p "Commit and publish? " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + git -C public add . + git -C public commit -m "Publish site" + git -C public push origin master + fi fi echo "Cleaning up..."