Convert skipHookPrefix to skipHookPrefixes (string to []string)#5338
Open
slavshik wants to merge 2 commits intojesseduffield:masterfrom
Open
Convert skipHookPrefix to skipHookPrefixes (string to []string)#5338slavshik wants to merge 2 commits intojesseduffield:masterfrom
slavshik wants to merge 2 commits intojesseduffield:masterfrom
Conversation
02afe73 to
69b1cc2
Compare
e1e1ca9 to
d3cd3da
Compare
d3cd3da to
a38a949
Compare
Collaborator
stefanhaller
left a comment
There was a problem hiding this comment.
Thanks. I pushed a bunch of fixups, see comments below.
pkg/commands/git_commands/commit.go
Outdated
| description += "\n\n" + newDescription | ||
| } | ||
| cmdArgs := NewGitCmd("commit"). | ||
| ArgIf(self.hasSkipHookPrefix("amend! "), "--no-verify"). |
Collaborator
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
Hello @stefanhaller
Thanks for you feedback! Hope I understood you correctly.
CreateFixupCommitnow takes the original commit subject and checks"fixup! " + originalSubjectagainst skip hook prefixes (instead of just the literal"fixup! "), so it correctly skips hooks only when the full fixup subject matches a configured prefix.CreateAmendCommitnow checksnewSubjectagainst 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
4a99413 to
048c263
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 15 |
| Duplication | 21 |
TIP This summary will be updated as you push new changes. Give us feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
git.skipHookPrefix(single string) togit.skipHookPrefixes(array of strings), allowing users to specify multiple prefixes that skip git hooks (e.g.["WIP", "fixup!", "squash!", "amend!"])skipHookPrefixscalar to the newskipHookPrefixessequence for backward compatibility["WIP"]preserving existing behaviorCloses #2275
Test plan
make build— compiles successfullygo test ./... -short— all unit tests passmake lint— no lint errorsmake generate— schema/docs regeneratedCommitCmdObj,CreateFixupCommit,CreateAmendCommit🤖 Generated with Claude Code