Skip to content

Commit 8d6d71f

Browse files
committed
[Workspace] Conform some types to CustomStringConvertible
1 parent 9486ee6 commit 8d6d71f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Sources/Workspace/CheckoutState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Utility
1616
/// A checkout state represents the current state of a repository.
1717
///
1818
/// A state will always has a revision. It can also have a branch or a version but not both.
19-
public struct CheckoutState: Equatable {
19+
public struct CheckoutState: Equatable, CustomStringConvertible {
2020

2121
/// The revision of the checkout.
2222
public let revision: Revision

Sources/Workspace/ManagedDependency.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import Utility
1818
///
1919
/// Each dependency will have a checkout containing the sources at a
2020
/// particular revision, and may have an associated version.
21-
public final class ManagedDependency: JSONMappable, JSONSerializable {
21+
public final class ManagedDependency: JSONMappable, JSONSerializable, CustomStringConvertible {
2222

2323
/// Represents the state of the managed dependency.
24-
public enum State: Equatable {
24+
public enum State: Equatable, CustomStringConvertible {
2525

2626
/// The dependency is a managed checkout.
2727
case checkout(CheckoutState)
@@ -41,6 +41,17 @@ public final class ManagedDependency: JSONMappable, JSONSerializable {
4141
if case .checkout = self { return true }
4242
return false
4343
}
44+
45+
public var description: String {
46+
switch self {
47+
case .checkout(let checkout):
48+
return "\(checkout)"
49+
case .edited:
50+
return "edited"
51+
case .local:
52+
return "local"
53+
}
54+
}
4455
}
4556

4657
/// The package reference.
@@ -132,6 +143,10 @@ public final class ManagedDependency: JSONMappable, JSONSerializable {
132143
"state": state,
133144
])
134145
}
146+
147+
public var description: String {
148+
return "<ManagedDependency: \(packageRef.name ?? packageRef.identity) \(state)>"
149+
}
135150
}
136151

137152
extension ManagedDependency.State: JSONMappable, JSONSerializable {

0 commit comments

Comments
 (0)