-
Notifications
You must be signed in to change notification settings - Fork 506
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
CLI patterns differ on Windows vs Linux #2781
Comments
Hi @janphkre |
Yes, that is correct. The test is failing on Windows:
|
This test succeeds on MacOs, and according to OP of #2781 it breaks on Windows OS. Verify whether this test also breaks in build pipeline.
The Your test does not fail on Linux as Linux has case sensitive paths. If you would alter the pattern in your test to Changing your test as follows, shows that the results on Windows and Linux both fail for same reason as you reported above:
Changing the glob to |
After doing some more testing, I still believe that there is something not working as intended with the way two conesecutive aserisks are being handled in ktlint. The difference in behaviour may come from the case sensitivity of the file system, but that is not the exact issue I was trying to point out here. You correctly acknowledged the behaviour in your comment:
This means, that anything before the
So the issue I want to point out here is, that ktlint is somehow ommitting any slash before a |
According to https://git-scm.com/docs/gitignore a trailing `**` in a glob has to match with any file in the directory that matches the glob without that trailing `**`. Given glob "**/Test*/**" the file "src/Foo/TestFoo.kt" should not be matched, and file "src/TestFoo/FooTest.kt" is matched. If the original pattern would be expanded with additional pattern "**/Test*" then both files would have been matched. Closes #2781
According to https://git-scm.com/docs/gitignore a trailing `**` in a glob has to match with any file in the directory that matches the glob without that trailing `**`. Given glob "**/Test*/**" the file "src/Foo/TestFoo.kt" should not be matched, and file "src/TestFoo/FooTest.kt" is matched. If the original pattern would be expanded with additional pattern "**/Test*" then both files would have been matched. Closes #2781
Thanks for pointing this out. The way in which is traling |
According to https://git-scm.com/docs/gitignore a trailing `**` in a glob has to match with any file in the directory that matches the glob without that trailing `**`. Given glob "**/Test*/**" the file "src/Foo/TestFoo.kt" should not be matched, and file "src/TestFoo/FooTest.kt" is matched. If the original pattern would be expanded with additional pattern "**/Test*" then both files would have been matched. Closes #2781
Expected Behavior
The glob patterns as described in https://pinterest.github.io/ktlint/latest/install/cli/#globs should work the same way running ktlint on any underlying operating system and should match the same files given the same file structure.
Observed Behavior
At the moment (using 1.3.1) glob patterns do not match the same files on Windows as on Linux.
Here are two examples:
*.kt
matches any file with the .kt file-ending in any subdirectory on Windows, however the same glob does not match any subdirectory on Linux.**/test*/**
seems to drop / ignore the second slash on Windows, since it matches a file at the location "src/example/TestFile.kt". On Linux this behaviour can not be observed.Generally Linux seems to be in line with the git manpage and online glob testing sites.
I suspect that the single star wildcard is not being handled correctly on Windows machines.
Sadly, the ktlint command does not produce any meaning full tracing output, similar to the test's output mentione below (with trace logging enabled):
Steps to Reproduce
Following test can be added to https://github.com/pinterest/ktlint/blob/master/ktlint-cli/src/test/kotlin/com/pinterest/ktlint/cli/internal/FileUtilsTest.kt
Your Environment
The text was updated successfully, but these errors were encountered: