diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f03764a..d033b35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,10 +74,26 @@ refactor!: rename ClientV1 to Client (BREAKING CHANGE) ``` **Co-authors:** do not add `Co-authored-by:` trailers. Commits should list -only the human author. Optional local hook: +only the human author. Install hooks with: ```bash -git config core.hooksPath .githooks +make hooks +``` + +This enables lefthook (format/lint/conventional commits) and the tracked +`.githooks/prepare-commit-msg` strip hook. + +**Cursor / IDE commits:** some editors inject `Co-authored-by: Cursor` via their +own git hooks. Use: + +```bash +./scripts/commit-clean.sh -m "fix(scope): your message" +``` + +**After a history rewrite:** reset stale local SHAs with: + +```bash +./scripts/sync-clone.sh ``` ## Pull request checklist diff --git a/Makefile b/Makefile index cf1a78e..33bccd6 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,12 @@ clean: ## Remove build artefacts. help: ## Show this help. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' -.PHONY: hooks -hooks: +.PHONY: hooks sync-clone +hooks: ## Install git hooks (lefthook + tracked .githooks prepare-commit-msg). + @command -v lefthook >/dev/null 2>&1 || (echo "install: go install github.com/evilmartians/lefthook@latest" && exit 1) git config core.hooksPath .githooks + lefthook install + +sync-clone: ## Hard-reset eyrie to origin/main (post history rewrite). + @chmod +x scripts/sync-clone.sh scripts/commit-clean.sh + @./scripts/sync-clone.sh diff --git a/scripts/commit-clean.sh b/scripts/commit-clean.sh new file mode 100755 index 0000000..52a2e17 --- /dev/null +++ b/scripts/commit-clean.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Commit without IDE-injected Co-authored-by trailers (Cursor, etc.). +# Usage: ./scripts/commit-clean.sh [-m "message"] [other git commit args...] +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" +exec git -c core.hooksPath=/dev/null commit "$@" diff --git a/scripts/sync-clone.sh b/scripts/sync-clone.sh new file mode 100755 index 0000000..b3ac907 --- /dev/null +++ b/scripts/sync-clone.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Hard-reset eyrie to origin/main. Use after a history rewrite or stale SHAs. +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" + +echo "==> Fetching origin" +git fetch origin + +echo "==> Resetting eyrie to origin/main" +git checkout main +git reset --hard origin/main + +echo "==> Done. eyrie: $(git rev-parse --short HEAD)"