narrow-vegetable-37489
03/14/2022, 1:35 PMbuf breaking
needs a previous state to compare against in order to detect breaking changes. My naive approach is to simply piggyback on Pants' pants.base.build_environment.get_git
and pants.vcs.changed.ChangedOptions
functionality. get_git
to get the git workdir (from the currently protected _gitdir
attribute) and `ChangedOptions.diffspec`/`ChangedOptions.since` to get the rev to compare the local tree against. If `ChangedOptions.diffspec`/`ChangedOptions.since` it can fall back on HEAD
, and if get_git
returns None
then the linter will be skipped I guess?
I'm not entirely sure how to put it all together. get_git
seems to be callable from anywhere, so that should be simple enough, but ChangedOptions
I'm struggling to get into my linter rule, probably because it's not intended to be used directly by rules but rather to determine which sources to provide the rules with.
I'm also pondering about on how to structure the code and its options. The current linter is located in pants/backend/codegen/protobuf/lint/buf
. Is this even a linter, or is a test or a check? Right now I've renamed the current rules.py
to lint_rules.py
and have introduce breaking_rules.py
. I imagine people will want the option to only enable/disable one of them, so bundling them in the same backend might not be the best approach. Then there's also the subsystem which I, of course, want to reuse for both, but should it be extended so lint
and breaking
have different options_scope
perhaps?
I appreciate any and all feedback 🖖