Skip to content

Commit 21152b8

Browse files
authored
Merge pull request #2958 from abertelrud/eng/throw-a-specific-error-for-any-git-operation-failure
Add a customized GitRepositoryError and funnel all Git operations through a method that throws one of those if an operation fails.
2 parents 0520891 + a3f011c commit 21152b8

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)