Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOWTO: advanced filters check for file rename only #152

Open
iamtodor-fb opened this issue Aug 22, 2022 · 3 comments
Open

HOWTO: advanced filters check for file rename only #152

iamtodor-fb opened this issue Aug 22, 2022 · 3 comments

Comments

@iamtodor-fb
Copy link

Hello,

I find the following options https://github.com/dorny/paths-filter/blob/master/README.md?plain=1#L446
I was able to configure not to run linter on deleted python files by having the filter

with:
          list-files: 'shell'
          filters: |
            py_scripts_filter:
              - added|modified: '**/*.py'

But it does not work on renamed files: R: renaming of a file: https://git-scm.com/docs/git-diff/2.12.5.

Let's say you have a foo.py, you renamed it to bar.py, and you did not modify the file's content but the linter still runs against it.

Is it possible to configure the linter not to run on this kind of change?

@petermetz
Copy link
Contributor

Not sure if I have the exact same or just a similar issue, but here we go:
I noticed that renames are ignored altogether: https://github.com/dorny/paths-filter/blob/master/src/main.ts#L185-L187
and would like to have an option/flag/etc. to include them because in some of the languages we use renaming the file can break the build quite easily if references to that file were not updated correctly (think of import statements in Typescript).
Based on that, we would prefer to be extra cautions and detect renames as meaningful changes that trigger test execution which would then tell us that there were bugs in the diff that did the renaming.

@dorny
Copy link
Owner

dorny commented Mar 2, 2024

@petermetz Looking at the code, it seems I've intentionally implemented rename to be equal to deleting and adding the new file. I wrote this part a long time ago so I don't remember all details now. I'm open to using a config parameter to change this behavior while keeping the default as it is now to avoid breaking changes.

If you prepare PR, I will review it as soon as possible. Otherwise, I can't promise when the feature will be available.

@petermetz
Copy link
Contributor

@petermetz Looking at the code, it seems I've intentionally implemented rename to be equal to deleting and adding the new file. I wrote this part a long time ago so I don't remember all details now. I'm open to using a config parameter to change this behavior while keeping the default as it is now to avoid breaking changes.

If you prepare PR, I will review it as soon as possible. Otherwise, I can't promise when the feature will be available.

@dorny A very reasonable proposition, thank you! I'm also quite short on time and this is not a high priority item for us either, so it might take a while, but I'll certainly look into sending a PR. Thank you very much for taking the time to evaluate the issue and also thank you for the great tool/project in general!

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

No branches or pull requests

3 participants