<#20905 Add exit-non-zero-on-fix support for fix ...
# github-notifications
c
#20905 Add exit-non-zero-on-fix support for fix and fmt goals Issue created by njgrisafi Is your feature request related to a problem? Please describe. We want to use Pants for various linting/formatting checks, including in a pre-commit hook. One challenge with Pants in that workflow is when we run
pants fix fmt lint
and it applies autofixes it doesn't exit with 1. We need pre-commit to fail so the developer has a chance to include those fixes in the commit. By contrast, ruff has a --exit-non-zero-on-fix flag which allows this to be differentiated. Describe the solution you'd like Maybe some global setting like
pants --exit-non-zero-on-fix fix fmt
Then when autoformating or autofixing occurs the exit code is non-zero failing notifying the caller there were some issues. Describe alternatives you've considered Inspecting changed files and parsing output from pants. This is not ideal. I guess we could do
pants lint fix fmt
as long as it runs
lint
first then the next goals. However, the output can be confusing for developers if some lint failures were autofixed. pantsbuild/pants