Skip to content

Commit

Permalink
fix: searching for files in symlinked directories (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek authored Nov 1, 2024
1 parent ef51eeb commit 4397564
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tuist/swift-glob",
"state" : {
"revision" : "c086760260c4bd6541ea42fdbb8cc76a9798b3fa",
"version" : "0.3.6"
"revision" : "106ff5ea97cca6ee504765133af3175ecd5ca257",
"version" : "0.3.7"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
.package(url: "https://github.com/weichsel/ZIPFoundation", .upToNextMajor(from: "0.9.19")),
// We are depending on a fork as swift-glob currently can't handle some scenario that we need in tuist/tuist.
// For example, the package currently goes through all directories regradless of whether that's necessary.'
.package(url: "https://github.com/tuist/swift-glob", .upToNextMajor(from: "0.3.6")),
.package(url: "https://github.com/tuist/swift-glob", .upToNextMajor(from: "0.3.7")),
],
targets: [
.target(
Expand Down
26 changes: 26 additions & 0 deletions Tests/FileSystemTests/FileSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -760,4 +760,30 @@ final class FileSystemTests: XCTestCase, @unchecked Sendable {
XCTAssertEqual(got, [firstDirectory, sourceFile, secondDirectory])
}
}

func test_glob_with_symlink_and_only_a_directory_wildcard() async throws {
try await subject.runInTemporaryDirectory(prefix: "FileSystem") { temporaryDirectory in
// Given
let firstDirectory = temporaryDirectory.appending(component: "first")
let symlink = firstDirectory.appending(component: "symlink")
let secondDirectory = temporaryDirectory.appending(component: "second")
let sourceFile = secondDirectory.appending(component: "file.swift")
let symlinkSourceFilePath = symlink.appending(component: "file.swift")
try await subject.makeDirectory(at: firstDirectory)
try await subject.makeDirectory(at: secondDirectory)
try await subject.touch(sourceFile)
try await subject.createSymbolicLink(from: symlink, to: secondDirectory)

// When
let got = try await subject.glob(
directory: firstDirectory,
include: ["**/*.swift"]
)
.collect()
.sorted()

// Then
XCTAssertEqual(got, [symlinkSourceFilePath])
}
}
}

0 comments on commit 4397564

Please sign in to comment.