From 6a7e372b10b8aceb46bb7f6251df9efea9d4a77d Mon Sep 17 00:00:00 2001 From: Oswaldo Rubio Date: Thu, 10 Nov 2022 10:44:48 +0100 Subject: [PATCH] ignore failed task in the TaskGroup (#13) * ignore failed task in the TaskGroup * update version --- Sources/jungle/Commands/HistoryCommand.swift | 17 ++++++++++++----- Sources/jungle/Commands/Main.swift | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/jungle/Commands/HistoryCommand.swift b/Sources/jungle/Commands/HistoryCommand.swift index e5aa8ca..2aeef89 100644 --- a/Sources/jungle/Commands/HistoryCommand.swift +++ b/Sources/jungle/Commands/HistoryCommand.swift @@ -57,13 +57,20 @@ struct HistoryCommand: AsyncParsableCommand { let current = try await GitLogEntry.current.process(pod: pod, podfile: String(contentsOf: podfileURL), target: currentTargetDependencies) // process Podfile.lock for past commits - let output = try await withThrowingTaskGroup(of: HistoryStatsOutput.self, returning: [HistoryStatsOutput].self) { group in + + let output = await withTaskGroup(of: HistoryStatsOutput?.self, returning: [HistoryStatsOutput].self) { group in for entry in logs.lazy { group.addTask { - let podfile = try shell("git show \(entry.revision):Podfile", at: directoryURL) - let entryTargetDependencies = try moduleFromPodfile(podfile, on: target) ?? .init(name: target, dependencies: []) - return try await entry.process( + + guard + let podfile = try? shell("git show \(entry.revision):Podfile", at: directoryURL), + let entryTargetDependencies = try? moduleFromPodfile(podfile, on: target) ?? .init(name: target, dependencies: []) + else { + return nil + } + + return try? await entry.process( pod: pod, podfile: shell("git show \(entry.revision):Podfile.lock", at: directoryURL), target: entryTargetDependencies @@ -72,7 +79,7 @@ struct HistoryCommand: AsyncParsableCommand { } var rows: [HistoryStatsOutput] = [] - for try await row in group { + for await row in group.compactMap({ $0 }) { rows.append(row) } return rows diff --git a/Sources/jungle/Commands/Main.swift b/Sources/jungle/Commands/Main.swift index 8576e21..1f325d5 100644 --- a/Sources/jungle/Commands/Main.swift +++ b/Sources/jungle/Commands/Main.swift @@ -5,7 +5,7 @@ struct Jungle: AsyncParsableCommand { static var configuration = CommandConfiguration( commandName: "jungle", abstract: "Displays dependency statistics", - version: "1.0.2", + version: "1.0.3", subcommands: [HistoryCommand.self, CompareCommand.self, GraphCommand.self], defaultSubcommand: CompareCommand.self )