Skip to content

Commit 0143776

Browse files
authored
docs: add sync-clone and commit-clean helpers; align make hooks with lefthook (#43)
Add clone reset and IDE-safe commit scripts, update CONTRIBUTING, and wire make hooks to lefthook plus tracked .githooks prepare-commit-msg.
1 parent 2f5efc2 commit 0143776

4 files changed

Lines changed: 47 additions & 4 deletions

File tree

CONTRIBUTING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,26 @@ refactor!: rename ClientV1 to Client (BREAKING CHANGE)
7474
```
7575

7676
**Co-authors:** do not add `Co-authored-by:` trailers. Commits should list
77-
only the human author. Optional local hook:
77+
only the human author. Install hooks with:
7878

7979
```bash
80-
git config core.hooksPath .githooks
80+
make hooks
81+
```
82+
83+
This enables lefthook (format/lint/conventional commits) and the tracked
84+
`.githooks/prepare-commit-msg` strip hook.
85+
86+
**Cursor / IDE commits:** some editors inject `Co-authored-by: Cursor` via their
87+
own git hooks. Use:
88+
89+
```bash
90+
./scripts/commit-clean.sh -m "fix(scope): your message"
91+
```
92+
93+
**After a history rewrite:** reset stale local SHAs with:
94+
95+
```bash
96+
./scripts/sync-clone.sh
8197
```
8298

8399
## Pull request checklist

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ clean: ## Remove build artefacts.
115115
help: ## Show this help.
116116
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
117117

118-
.PHONY: hooks
119-
hooks:
118+
.PHONY: hooks sync-clone
119+
hooks: ## Install git hooks (lefthook + tracked .githooks prepare-commit-msg).
120+
@command -v lefthook >/dev/null 2>&1 || (echo "install: go install github.com/evilmartians/lefthook@latest" && exit 1)
120121
git config core.hooksPath .githooks
122+
lefthook install
123+
124+
sync-clone: ## Hard-reset eyrie to origin/main (post history rewrite).
125+
@chmod +x scripts/sync-clone.sh scripts/commit-clean.sh
126+
@./scripts/sync-clone.sh

scripts/commit-clean.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# Commit without IDE-injected Co-authored-by trailers (Cursor, etc.).
3+
# Usage: ./scripts/commit-clean.sh [-m "message"] [other git commit args...]
4+
set -euo pipefail
5+
6+
cd "$(git rev-parse --show-toplevel)"
7+
exec git -c core.hooksPath=/dev/null commit "$@"

scripts/sync-clone.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# Hard-reset eyrie to origin/main. Use after a history rewrite or stale SHAs.
3+
set -euo pipefail
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
7+
echo "==> Fetching origin"
8+
git fetch origin
9+
10+
echo "==> Resetting eyrie to origin/main"
11+
git checkout main
12+
git reset --hard origin/main
13+
14+
echo "==> Done. eyrie: $(git rev-parse --short HEAD)"

0 commit comments

Comments
 (0)