Skip to content

Convert skipHookPrefix to skipHookPrefixes (string to []string)#5338

Open
slavshik wants to merge 2 commits intojesseduffield:masterfrom
slavshik:fix-skip-hook-prefixes
Open

Convert skipHookPrefix to skipHookPrefixes (string to []string)#5338
slavshik wants to merge 2 commits intojesseduffield:masterfrom
slavshik:fix-skip-hook-prefixes

Conversation

@slavshik
Copy link
Copy Markdown

@slavshik slavshik commented Mar 4, 2026

I've created this PR since the #2275 issue bothered me for quite a while and there were no option(s) to resolve it on config level for my case.

Summary

  • Converts git.skipHookPrefix (single string) to git.skipHookPrefixes (array of strings), allowing users to specify multiple prefixes that skip git hooks (e.g. ["WIP", "fixup!", "squash!", "amend!"])
  • Adds a config migration from the old skipHookPrefix scalar to the new skipHookPrefixes sequence for backward compatibility
  • Default value remains ["WIP"] preserving existing behavior

Closes #2275

Test plan

  • make build — compiles successfully
  • go test ./... -short — all unit tests pass
  • make lint — no lint errors
  • make generate — schema/docs regenerated
  • New test cases for multiple prefixes in CommitCmdObj, CreateFixupCommit, CreateAmendCommit
  • Migration test cases: old field only, new field only, both present, neither present

🤖 Generated with Claude Code

@slavshik slavshik force-pushed the fix-skip-hook-prefixes branch from 02afe73 to 69b1cc2 Compare March 4, 2026 09:58
@slavshik slavshik force-pushed the fix-skip-hook-prefixes branch 2 times, most recently from e1e1ca9 to d3cd3da Compare March 25, 2026 18:08
@stefanhaller stefanhaller force-pushed the fix-skip-hook-prefixes branch from d3cd3da to a38a949 Compare March 30, 2026 10:45
Copy link
Copy Markdown
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

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

Thanks. I pushed a bunch of fixups, see comments below.

description += "\n\n" + newDescription
}
cmdArgs := NewGitCmd("commit").
ArgIf(self.hasSkipHookPrefix("amend! "), "--no-verify").
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here, however it's unclear to me whether "amend! "+originalSubject or newSubject should be used for the check. Probably the latter, actually: creating an amend! commit with the subject amend! WIP and the body This is the real subject renames a WIP commit to a non-WIP commit, and you probably do want to run the hooks on it from then on.

Copy link
Copy Markdown
Author

@slavshik slavshik Apr 8, 2026

Choose a reason for hiding this comment

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

Hello @stefanhaller

Thanks for you feedback! Hope I understood you correctly.

  • CreateFixupCommit now takes the original commit subject and checks "fixup! " + originalSubject against skip hook prefixes (instead of just the literal "fixup! "), so it correctly skips hooks only when the full fixup subject matches a configured prefix.
  • CreateAmendCommit now checks newSubject against skip hook prefixes (instead of "amend! "), so renaming a WIP commit to a non-WIP subject correctly runs hooks. 048c263
  • And I’ve squashed your fixes with mine. cd27ff5

@slavshik slavshik force-pushed the fix-skip-hook-prefixes branch from 4a99413 to 048c263 Compare April 8, 2026 20:03
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · 21 duplication

Metric Results
Complexity 15
Duplication 21

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

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.

Allow precommit-bypassing fixup! commit

2 participants