From 3ee0c874c50767d4b9ca6a8d06760ea9f79c73f4 Mon Sep 17 00:00:00 2001 From: Lakshman Patel Date: Thu, 18 Jun 2026 16:35:42 +0530 Subject: [PATCH] fix: drop tracked .githooks; use lefthook-only hook install Remove tracked .githooks wrappers that conflicted with lefthook install, gitignore the whole .githooks/ dir, and unset core.hooksPath in make hooks. --- .githooks/pre-commit | 8 -------- .githooks/prepare-commit-msg | 16 ---------------- .gitignore | 6 ++---- CONTRIBUTING.md | 3 +-- Makefile | 4 ++-- 5 files changed, 5 insertions(+), 32 deletions(-) delete mode 100755 .githooks/pre-commit delete mode 100755 .githooks/prepare-commit-msg diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index c7450c5..0000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Run ast-grep on staged Go files -STAGED=$(git diff --cached --name-only --diff-filter=ACMR | grep '\.go$' || true) -if [ -n "$STAGED" ]; then - if command -v sg >/dev/null 2>&1; then - echo "$STAGED" | xargs sg scan 2>&1 | head -20 - fi -fi diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg deleted file mode 100755 index 6770504..0000000 --- a/.githooks/prepare-commit-msg +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# Auto-strip Co-authored-by trailers and enforce conventional commits -COMMIT_MSG_FILE=$1 -COMMIT_SOURCE=$2 - -# Skip merge commits, amend, etc. -if [ "$COMMIT_SOURCE" = "merge" ] || [ "$COMMIT_SOURCE" = "squash" ]; then - exit 0 -fi - -# Strip Co-authored-by lines (portable sed — works on macOS and Linux). -sed '/^[Cc]o-[Aa]uthored-[Bb]y:/d' "$COMMIT_MSG_FILE" > "${COMMIT_MSG_FILE}.tmp" && mv "${COMMIT_MSG_FILE}.tmp" "$COMMIT_MSG_FILE" - -# Remove trailing blank lines. -sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$COMMIT_MSG_FILE" > "${COMMIT_MSG_FILE}.tmp" 2>/dev/null && mv "${COMMIT_MSG_FILE}.tmp" "$COMMIT_MSG_FILE" || true - diff --git a/.gitignore b/.gitignore index 325c77b..78a10ec 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,5 @@ dist/ .DS_Store coverage.out -# Lefthook-generated wrappers (tracked .githooks/prepare-commit-msg is canonical) -.githooks/commit-msg -.githooks/pre-push -.githooks/pre-commit.old +# Lefthook-generated wrappers (logic lives in lefthook.yml) +.githooks/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d033b35..836e6f3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,8 +80,7 @@ only the human author. Install hooks with: make hooks ``` -This enables lefthook (format/lint/conventional commits) and the tracked -`.githooks/prepare-commit-msg` strip hook. +This enables lefthook (format/lint/conventional commits/co-author strip). **Cursor / IDE commits:** some editors inject `Co-authored-by: Cursor` via their own git hooks. Use: diff --git a/Makefile b/Makefile index 33bccd6..3d567cf 100644 --- a/Makefile +++ b/Makefile @@ -116,9 +116,9 @@ 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 sync-clone -hooks: ## Install git hooks (lefthook + tracked .githooks prepare-commit-msg). +hooks: ## Install git hooks via lefthook (format, lint, conventional commits, co-author strip). @command -v lefthook >/dev/null 2>&1 || (echo "install: go install github.com/evilmartians/lefthook@latest" && exit 1) - git config core.hooksPath .githooks + git config --unset core.hooksPath 2>/dev/null || true lefthook install sync-clone: ## Hard-reset eyrie to origin/main (post history rewrite).