policy-bot icon indicating copy to clipboard operation
policy-bot copied to clipboard

feat: no_changed_files predicate

Open erikburt opened this issue 1 year ago • 2 comments

Summary

Adds a new no_changed_files predicate that allows you to ensure that the rule is not applied if a file matching an entry in no_changed_files.paths is present.

This is a negation of the changed_files predicate, and the implementation logic reflects that.

Closes #754 Related #755

erikburt avatar Apr 17 '24 18:04 erikburt

Thanks for your interest in palantir/policy-bot, @erikburt! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

palantirtech avatar Apr 17 '24 18:04 palantirtech

Thanks for implementing this. I think it looks good, but I need to think a bit more about:

  • If the expected behavior is exactly the negation of changed_files or if there should be some difference (particularly for ignored files)
  • If the value/condition phrases are correct for the UI

I'll try to get back to you on those points in the next few days.

bluekeyes avatar Apr 29 '24 05:04 bluekeyes

Thank you for the review! Sorry for the delay, was caught up with some deadlines.

I've changed the phrases around using some of your suggestions. To get around the weird double negatives I added a "SkipPhrase" to the predicate result which is universally "do not" except for the NoChangedFiles predicate where it is empty.

I've also tried to simplify the logic where possible. I do think it's probably best to reuse the ChangedFiles predicate to ensure this is a direct negation. If you would like me to duplicate and reverse the logic, I can do that as well.

Let me know what you think.

erikburt avatar May 21 '24 22:05 erikburt