Skip to content

fix: scope pre-commit lint to new issues only - #16

Merged
gonzaloserrano merged 2 commits into
mainfrom
gsr/fix-precommit-lint-scope
Apr 8, 2026
Merged

gonzaloserrano merged 2 commits into
mainfrom
gsr/fix-precommit-lint-scope

Conversation

@gonzaloserrano

Copy link
Copy Markdown
Owner

Summary

  • Use golangci-lint run --new instead of golangci-lint run so only issues in changed code are reported
  • Respect --no-verify flag to match git's own hook skip semantics

Why

The pre-commit hook runs golangci-lint on the entire repo. Pre-existing lint warnings block all commits even when the changes are clean.

Test plan

  • Commit in a Go repo with pre-existing lint issues: only new issues should be reported
  • Commit with --no-verify: hook should be skipped

golangci-lint was running on the entire repo, so pre-existing
lint warnings blocked all commits even when the changes were
clean. Use --new flag to only report issues in changed code.

Also respect --no-verify to match git's own hook skip semantics.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/go-precommit.sh">

<violation number="1" location="scripts/go-precommit.sh:13">
P2: This only recognizes `--no-verify`; include `-n` as well to match Git’s no-verify semantics.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread scripts/go-precommit.sh
fi

# Respect --no-verify (same semantics as git's own hook skip)
if [[ "$command" =~ --no-verify ]]; then

@cubic-dev-ai cubic-dev-ai Bot Apr 8, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This only recognizes --no-verify; include -n as well to match Git’s no-verify semantics.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/go-precommit.sh, line 13:

<comment>This only recognizes `--no-verify`; include `-n` as well to match Git’s no-verify semantics.</comment>

<file context>
@@ -9,6 +9,11 @@ if [[ ! "$command" =~ ^git\ commit ]]; then
 fi
 
+# Respect --no-verify (same semantics as git's own hook skip)
+if [[ "$command" =~ --no-verify ]]; then
+  exit 0
+fi
</file context>
Suggested change
if [[ "$command" =~ --no-verify ]]; then
if [[ "$command" =~ (^|[[:space:]])(-n|--no-verify)([[:space:]]|$) ]]; then
Fix with Cubic

@gonzaloserrano
gonzaloserrano merged commit 655252a into main Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant