Skip to content

fix: Prevent orphan changes from go fmt/tidy/fix in precommit checks#2350

Merged
jcscottiii merged 1 commit intomainfrom
fix/orphan-changes
Mar 19, 2026
Merged

fix: Prevent orphan changes from go fmt/tidy/fix in precommit checks#2350
jcscottiii merged 1 commit intomainfrom
fix/orphan-changes

Conversation

@jcscottiii
Copy link
Collaborator

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.

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.
@jcscottiii jcscottiii enabled auto-merge March 19, 2026 19:50
@jcscottiii jcscottiii added this pull request to the merge queue 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question, why do we include a check for unstaged-changes in the precommit target?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

@jcscottiii jcscottiii Mar 19, 2026

Choose a reason for hiding this comment

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

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.

Merged via the queue into main with commit c50bdbe Mar 19, 2026
8 checks passed
@jcscottiii jcscottiii deleted the fix/orphan-changes branch March 19, 2026 20:42
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.

3 participants