Skip to content

Commit

Permalink
ignore failed task in the TaskGroup (#13)
Browse files Browse the repository at this point in the history
* ignore failed task in the TaskGroup

* update version
  • Loading branch information
osrufung authored Nov 10, 2022
1 parent 39c51c4 commit 6a7e372
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions Sources/jungle/Commands/HistoryCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/jungle/Commands/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 6a7e372

Please sign in to comment.