-
Notifications
You must be signed in to change notification settings - Fork 826
Ignore normal directory with dots #397
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
Conversation
“.bundle” Sent with GitHawk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could potentially break a lot of projects that were relying on directories with an extension to be a file
Yea I worry about it too, but if we thought about it at first time, this should be the correct approach, isn't it? |
"xcassets", | ||
"complicationset", | ||
"appiconset", | ||
"xcdatamodeld"].contains(ex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add "bundle" and "framework" to this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is an API to detect this? It seems to be OS defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found an API to get UTI in string. 1e21b1d
It's "public.folder"
if it's a normal folder.
lproj
appears to be "public.folder"
too. It looks problematic, but we're whitelisting lproj
, so it wouldn't be a problem.
|
extension Path { | ||
|
||
/// Treat this as a resource instead of a normal directory. | ||
var isNonFolderDirectory: Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNonFolderDirectory
sounds a bit ambiguous. What about isGroupDirectory
? That's how Xcode names directories in an Xcode project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you could just say !myPath.isGroupDirectory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I think it's depends on how you look at the problem.
From Xcode perspective, isGroupDirectory
is maybe straight forward, but this specific functionality is seen outside of Xcode too. That's why I've put this as PathKitExtension
.
Also, I actually tried to rename it, and ended up with rather complicated code. (Needed additional is a directory, but
condition to retrieve non "public.folder" directory.)
let directories = children
.filter { $0.isDirectory && $0.isGroupDirectory && $0.extension != "lproj" }
.sorted { $0.lastComponent < $1.lastComponent }
let filePaths = children
.filter { $0.isFile || ($0.isDirectory && !$0.isGroupDirectory) }
.sorted { $0.lastComponent < $1.lastComponent }
Therefore, I think it's better to define this way (isNonFolderDirectory
) in whitelist manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about isFileDirectory
? I agree that isNonFolderDirectory
is a bit strange of a name. The actual logic doesn't need to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3aac581
.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey]) | ||
.typeIdentifier { | ||
// NOTE: lproj is public.folder | ||
return uti != "public.folder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone looks at this code in three months, it's hard to say what it does. Which types of paths am I ignoring with this expression. Maybe it's worth adding a larger comment where you explain the rationale behind this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Will do. Maybe as a doc-comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 6933cde
Not making the most appropriate decision in the past doesn't justify that the "correct" approach should be introduced regardless of it breaking the contract with the projects that are already using the tool. What I would do is:
If it's not, there's a decision to be made: either introducing a breaking change and going with a major bump, or finding a way to roll this out in a non-breaking manner. @yonaskolb is the person to help you with that. |
Thanks, will do👌 |
Just found out how to list all recognized filetypes on mac. It lists all icons for each filetypes too. I'll collect filetypes from these things.
As a side note: |
} | ||
|
||
$0.it("supports frameworks in sources") { | ||
let directories = """ | ||
Sources: | ||
- Foo.framework | ||
- Foo.framework: | ||
- Foo.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.framework
is now required to be a directory, not file.
@pepibumur @yonaskolb
Added tests in b24a7bf .
(Sorry for poor readability. The original output is not in any standard format and is hard to parse.)
The behavior is different for normal directory with dots. They had been treated as |
} | ||
} | ||
|
||
// MARK: Utilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved utility functions below the all test cases. What we are interested in most is the test cases themselves, not utilities.
And this is the script to determine if a file extension has a special meaning or not. |
@yonaskolb |
return false | ||
} | ||
|
||
if let uti = try! URL(fileURLWithPath: self.string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to get the performance tests in (coming shortly) so this can be tested for performance
@toshi0383 Not sure why tests are failing either. |
Conflicts: Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj
Updated CHANGELOG in 9227503 |
Investigating CI failure. Maybe returned UTI is different on Mac VMs? |
77ca9b1
to
24fa8ab
Compare
24fa8ab
to
a6b925a
Compare
So we need to figure out how to determine if an UTI is from System, or from third party app. |
Closing for now. |
Fixes #396