Execute ruff only on staged changes #4049
-
We want to start using ruff to prevent bad code from making it into future PRs while we work on fixing the issues that Is there a way to only run ruff on git staged changes rather than the entire source code? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
I think you could use |
Beta Was this translation helpful? Give feedback.
-
I did find this snippet which may be able to help out. On mobile so not able to try it though - you'd probably need to fiddle around to change the command from |
Beta Was this translation helpful? Give feedback.
-
Ah yeah, unfortunately we don't support this right now, though it's come up a few times in different forms: #1149, #1931, #2696. I've generally been a bit hesitant to support it since it seems quite hard to get right. |
Beta Was this translation helpful? Give feedback.
-
Not really straightforward as having a direct option flag from
You can also do a similar thing on a CI pipeline over files changed via commits with respect to the master branch, for example in the case of a Merge Request pipeline on GitLab ,
|
Beta Was this translation helpful? Give feedback.
-
This works perfectly:
This commands you can run with pre-commit or lefthook. For example lefthook.yml config:
|
Beta Was this translation helpful? Give feedback.
Ah yeah, unfortunately we don't support this right now, though it's come up a few times in different forms: #1149, #1931, #2696. I've generally been a bit hesitant to support it since it seems quite hard to get right.