add makefile target: git/set-head
authorShane <chown_tee@proton.me>
Sun, 11 Jan 2026 03:18:56 +0000 (03:18 +0000)
committerShane <chown_tee@proton.me>
Sun, 11 Jan 2026 03:18:56 +0000 (03:18 +0000)
Makefile

index da8e8a02f9ad6cb77f445af87785f46873bb4127..4aff5358befa3dee3ef427346ad7cfe420b260c1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -187,3 +187,17 @@ endif
        ssh $(VPS) "git config --global --add safe.directory /srv/git/$(NEW_GIT)"
        @echo "Don't forget to update your local remote URL:"
        @echo "git remote set-url helio-web ssh://$(VPS_USER)@$(VPS_HOST)/srv/git/$(NEW_GIT)"
+
+.PHONY: git/set-head
+git/set-head: ##H @Remote Set default branch (HEAD) for a repo (usage: make git/set-head REPO=... BRANCH=main)
+ifndef REPO
+       $(error REPO is undefined. Usage: make git/set-head REPO=projects/repo.git BRANCH=main)
+endif
+ifndef BRANCH
+       $(error BRANCH is undefined. Usage: make git/set-head REPO=... BRANCH=main)
+endif
+       @# Auto-append .git if missing
+       $(eval REPO_GIT := $(if $(filter %.git,$(REPO)),$(REPO),$(REPO).git))
+       @echo "Setting HEAD of $(REPO_GIT) to refs/heads/$(BRANCH)..."
+       ssh $(VPS) "git --git-dir=/srv/git/$(REPO_GIT) symbolic-ref HEAD refs/heads/$(BRANCH)"
+       @echo "HEAD updated."