Skip to content

Commit 6a7e372

Browse files
authored
ignore failed task in the TaskGroup (#13)
* ignore failed task in the TaskGroup * update version
1 parent 39c51c4 commit 6a7e372

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Sources/jungle/Commands/HistoryCommand.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,20 @@ struct HistoryCommand: AsyncParsableCommand {
5757
let current = try await GitLogEntry.current.process(pod: pod, podfile: String(contentsOf: podfileURL), target: currentTargetDependencies)
5858

5959
// process Podfile.lock for past commits
60-
let output = try await withThrowingTaskGroup(of: HistoryStatsOutput.self, returning: [HistoryStatsOutput].self) { group in
60+
61+
let output = await withTaskGroup(of: HistoryStatsOutput?.self, returning: [HistoryStatsOutput].self) { group in
6162

6263
for entry in logs.lazy {
6364
group.addTask {
64-
let podfile = try shell("git show \(entry.revision):Podfile", at: directoryURL)
65-
let entryTargetDependencies = try moduleFromPodfile(podfile, on: target) ?? .init(name: target, dependencies: [])
66-
return try await entry.process(
65+
66+
guard
67+
let podfile = try? shell("git show \(entry.revision):Podfile", at: directoryURL),
68+
let entryTargetDependencies = try? moduleFromPodfile(podfile, on: target) ?? .init(name: target, dependencies: [])
69+
else {
70+
return nil
71+
}
72+
73+
return try? await entry.process(
6774
pod: pod,
6875
podfile: shell("git show \(entry.revision):Podfile.lock", at: directoryURL),
6976
target: entryTargetDependencies
@@ -72,7 +79,7 @@ struct HistoryCommand: AsyncParsableCommand {
7279
}
7380

7481
var rows: [HistoryStatsOutput] = []
75-
for try await row in group {
82+
for await row in group.compactMap({ $0 }) {
7683
rows.append(row)
7784
}
7885
return rows

Sources/jungle/Commands/Main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct Jungle: AsyncParsableCommand {
55
static var configuration = CommandConfiguration(
66
commandName: "jungle",
77
abstract: "Displays dependency statistics",
8-
version: "1.0.2",
8+
version: "1.0.3",
99
subcommands: [HistoryCommand.self, CompareCommand.self, GraphCommand.self],
1010
defaultSubcommand: CompareCommand.self
1111
)

0 commit comments

Comments
 (0)