fix: Prevent orphan changes from go fmt/tidy/fix in precommit checks#2350
Merged
jcscottiii merged 1 commit intomainfrom Mar 19, 2026
Merged
fix: Prevent orphan changes from go fmt/tidy/fix in precommit checks#2350jcscottiii merged 1 commit intomainfrom
jcscottiii merged 1 commit intomainfrom
Conversation
Previously, `make precommit` did not automatically run Go code formatting or tidy module dependencies before validating unstaged changes. This allowed dirty module states and formatting issues to quietly slip past local validation and CI into the main branch. Any test failures from the unstaged-changes check also lacked clarity for developers. This commit introduces the following improvements to the `Makefile`: - Appends `go-tidy` and `go-fix` to the main `precommit` check to execute these actions sequentially. - Enhances the `unstaged-changes` target with a human-readable print statement that clearly identifies when background `tidy` or `fmt` rules modified tracked files, blocking the commit pipeline until the user adds the clean code. This effectively ensures that all contributors run `go fix/tidy` correctly before merging their code.
szy196
approved these changes
Mar 19, 2026
neilv-g
reviewed
Mar 19, 2026
| clean: clean-gen clean-node port-forward-terminate minikube-delete | ||
|
|
||
| precommit: license-check lint unstaged-changes test | ||
| precommit: license-check go-fix go-tidy lint test unstaged-changes |
Collaborator
There was a problem hiding this comment.
Question, why do we include a check for unstaged-changes in the precommit target?
Collaborator
Author
There was a problem hiding this comment.
Good question! We technically should call the target presubmit. Some projects have a separate presubmit and precommit target. Whereas we kinda combine them both into one.
Collaborator
Author
There was a problem hiding this comment.
As they say: Naming is the hardest thing in CS lol.
With that said, more than happy to change that so that it's clearer.
neilv-g
approved these changes
Mar 19, 2026
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.
Previously,
make precommitdid not automatically run Go code formatting or tidy module dependencies before validating unstaged changes. This allowed dirty module states and formatting issues to quietly slip past local validation and CI into the main branch. Any test failures from the unstaged-changes check also lacked clarity for developers.This commit introduces the following improvements to the
Makefile:go-tidyandgo-fixto the mainprecommitcheck to execute these actions sequentially.unstaged-changestarget with a human-readable print statement that clearly identifies when backgroundtidyorfmtrules modified tracked files, blocking the commit pipeline until the user adds the clean code.This effectively ensures that all contributors run
go fix/tidycorrectly before merging their code.