Skip to content

Commit a3f011c

Browse files
committed
Add a customized GitRepositoryError and funnel all Git operations through a method that throws one of those if the operation fails. This makes sure that Git failures clients can distinguish from other Process errors (so failure handling can be customized), and that they all have a location.
1 parent e0791b3 commit a3f011c

File tree

4 files changed

+164
-87
lines changed

4 files changed

+164
-87
lines changed

Sources/PackageGraph/RepositoryPackageContainerProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public class RepositoryPackageContainer: BasePackageContainer, CustomStringConve
400400
}.1
401401
} catch {
402402
// Examine the error to see if we can come up with a more informative and actionable error message. We know that the revision is expected to be a branch name or a hash (tags are handled through a different code path).
403-
if let gitInvocationError = error as? ProcessResult.Error, gitInvocationError.description.contains("Needed a single revision") {
403+
if let error = error as? GitRepositoryError, error.description.contains("Needed a single revision") {
404404
// It was a Git process invocation error. Take a look at the repository to see if we can come up with a reasonable diagnostic.
405405
if let rev = try? repository.resolveRevision(identifier: revision), repository.exists(revision: rev) {
406406
// Revision does exist, so something else must be wrong.

0 commit comments

Comments
 (0)