Skip to content

Commit 6f58515

Browse files
authored
docs: add sync-clone and commit-clean helpers for post-rewrite clones (#57)
Add scripts to reset stale SHAs and commit without IDE co-author injection, plus make sync-submodules/sync-clone targets and CONTRIBUTING guidance.
1 parent 0b931dd commit 6f58515

4 files changed

Lines changed: 51 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ only the human author. Hooks are auto-installed by `make setup` via
8181
make hooks
8282
```
8383

84+
**Cursor / IDE commits:** some editors inject `Co-authored-by: Cursor` via their
85+
own git hooks. Use the clean commit helper to bypass IDE hooks while keeping
86+
lefthook checks on normal commits:
87+
88+
```bash
89+
./scripts/commit-clean.sh -m "fix(scope): your message"
90+
```
91+
92+
**After a history rewrite:** reset stale local SHAs with:
93+
94+
```bash
95+
./scripts/sync-clone.sh
96+
```
97+
8498
## Commit signing
8599

86100
Signed commits are required in this repo.

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,19 @@ compat-test: ## Validate testdata/compatibility-matrix.json and report the 'next
205205
compat-check: ## Strict validation — non-zero exit if any component lacks a version.
206206
@go run ./cmd/compat-test -matrix=next -strict -file=testdata/compatibility-matrix.json
207207

208-
.PHONY: hooks
208+
.PHONY: hooks sync-submodules sync-clone
209209
hooks: ## Install git hooks via lefthook (formatting, linting, conventional commits).
210210
@command -v lefthook >/dev/null 2>&1 || (echo "install: go install github.com/evilmartians/lefthook@latest" && exit 1)
211211
lefthook install
212+
213+
sync-submodules: ## Fetch and checkout latest origin/main for all external/ submodules.
214+
git submodule foreach 'git fetch origin && git checkout origin/main 2>/dev/null || git checkout origin/HEAD'
215+
@echo "Submodule heads:"
216+
@git submodule status
217+
218+
sync-clone: ## Hard-reset hawk and submodules to origin/main (post history rewrite).
219+
@chmod +x scripts/sync-clone.sh scripts/commit-clean.sh
220+
@./scripts/sync-clone.sh
212221
# === Cross-platform binary targets (add after existing 'build' target) ===
213222

214223
.PHONY: build-all build-static size-check

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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
# Hard-reset hawk and all external/ submodules to origin/main.
3+
# Use after a history rewrite or when your clone has stale SHAs.
4+
set -euo pipefail
5+
6+
cd "$(git rev-parse --show-toplevel)"
7+
8+
echo "==> Fetching origin"
9+
git fetch origin
10+
11+
echo "==> Resetting hawk to origin/main"
12+
git checkout main
13+
git reset --hard origin/main
14+
15+
echo "==> Updating submodules"
16+
git submodule update --init --recursive
17+
git submodule foreach 'git fetch origin && git checkout origin/main 2>/dev/null || git checkout origin/HEAD'
18+
19+
echo "==> Done. hawk: $(git rev-parse --short HEAD)"
20+
git submodule status

0 commit comments

Comments
 (0)