git » sparkle-arcade » commit 79f0ce6

enhance makefile

author Alan Dipert
2025-11-16 17:08:39 UTC
committer Alan Dipert
2025-11-16 17:08:39 UTC
parent 2d7f2878c0be2462a588f06b358f2ba423ce7888

enhance makefile

Makefile +18 -2

diff --git a/Makefile b/Makefile
index c58c96e..7531491 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: deploy clean
+.PHONY: deploy clean check-git-clean
 
 DIST_ITEMS := index.html styles.css blossom-blocks fairy-finder
 DEPLOY_TARGET ?= arsien23i2@dreamhost:tailrecursion.com/arcade/
@@ -7,9 +7,25 @@ RSYNC_FLAGS ?= -av --delete --chmod=F644,D755 --exclude='.DS_Store'
 clean:
 	find . -name '*.DS_Store' -delete
 
-deploy:
+deploy: check-git-clean
 	@if [ -z "$(DEPLOY_TARGET)" ]; then \
 		echo "DEPLOY_TARGET not set"; \
 		exit 1; \
 	fi
 	rsync $(RSYNC_FLAGS) $(DIST_ITEMS) $(DEPLOY_TARGET)
+	@if [ -d .git ]; then \
+		git push; \
+	else \
+		echo "Skipping git push (no .git directory)"; \
+	fi
+
+check-git-clean:
+	@if [ ! -d .git ]; then \
+		echo "Warning: not a git repository; skipping clean check."; \
+	else \
+		if [ -n "$$(git status --porcelain)" ]; then \
+			echo 'Refusing to deploy: git worktree has uncommitted changes.'; \
+			git status --short; \
+			exit 1; \
+		fi; \
+	fi