Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.7")),
.package(url: "https://github.com/tuist/swift-glob", .upToNextMajor(from: "0.3.8")),
],
targets: [
.target(
Expand Down
1 change: 0 additions & 1 deletion Sources/FileSystem/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ public struct FileSystem: FileSysteming, Sendable {
return Glob.search(
directory: URL(string: directory.pathString)!,
include: try include
.flatMap { $0.contains("**/") ? [$0.replacingOccurrences(of: "**/", with: ""), $0] : [$0] }
.map { try Pattern($0) },
skipHiddenFiles: false
)
Expand Down
31 changes: 31 additions & 0 deletions Tests/FileSystemTests/FileSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -786,4 +786,35 @@ final class FileSystemTests: XCTestCase, @unchecked Sendable {
XCTAssertEqual(got, [symlinkSourceFilePath])
}
}

func test_glob_with_double_directory_wildcard() async throws {
try await subject.runInTemporaryDirectory(prefix: "FileSystem") { temporaryDirectory in
// Given
let firstDirectory = temporaryDirectory.appending(component: "first")
let firstSourceFile = firstDirectory.appending(component: "first.swift")
let secondDirectory = firstDirectory.appending(component: "second")
let secondSourceFile = secondDirectory.appending(component: "second.swift")
let thirdDirectory = secondDirectory.appending(component: "third")
let thirdSourceFile = thirdDirectory.appending(component: "third.swift")
let fourthDirectory = thirdDirectory.appending(component: "fourth")
let fourthSourceFile = fourthDirectory.appending(component: "fourth.swift")

try await subject.makeDirectory(at: fourthDirectory)
try await subject.touch(firstSourceFile)
try await subject.touch(secondSourceFile)
try await subject.touch(thirdSourceFile)
try await subject.touch(fourthSourceFile)

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

// Then
XCTAssertEqual(got, [fourthSourceFile, thirdSourceFile])
}
}
}