File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed
Sources/DangerDependenciesResolver Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -38,3 +38,42 @@ extension Package.Pinned {
38
38
let version : Version
39
39
}
40
40
}
41
+
42
+ // MARK: swift-tools-version >= 5.6
43
+ extension Package {
44
+ struct PinnedV2 : Decodable , Equatable {
45
+ let name : String
46
+ let url : URL
47
+ let state : State
48
+ }
49
+ }
50
+
51
+ extension Package . PinnedV2 {
52
+ enum CodingKeys : String , CodingKey {
53
+ case name = " identity "
54
+ case url = " location "
55
+ case state
56
+ }
57
+ }
58
+
59
+ extension Package . PinnedV2 {
60
+ struct State : Decodable , Equatable {
61
+ let version : Version
62
+ }
63
+ }
64
+
65
+ extension Package . PinnedV2 {
66
+ func convertToV1( ) -> Package . Pinned {
67
+ . init(
68
+ name: name,
69
+ url: url,
70
+ state: . init( version: state. version)
71
+ )
72
+ }
73
+ }
74
+
75
+ extension Sequence where Element == Package . PinnedV2 {
76
+ func convertToV1( ) -> [ Package . Pinned ] {
77
+ map { $0. convertToV1 ( ) }
78
+ }
79
+ }
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ struct PackageDataProvider: PackageDataProviding {
63
63
/// swift-tools-version <= 5.5
64
64
case v1( object: Object )
65
65
/// swift-tools-version >= 5.6
66
- case v2( pins: [ Package . Pinned ] )
66
+ case v2( pins: [ Package . PinnedV2 ] )
67
67
}
68
68
let version : Version
69
69
@@ -80,7 +80,9 @@ struct PackageDataProvider: PackageDataProviding {
80
80
case 1 :
81
81
let object = try container. decode ( Object . self, forKey: . object)
82
82
self . version = . v1( object: object)
83
- // case 2:
83
+ case 2 :
84
+ let pins = try container. decode ( [ Package . PinnedV2 ] . self, forKey: . pins)
85
+ self . version = . v2( pins: pins)
84
86
default :
85
87
throw DecodingError . valueNotFound ( Int . self, . init( codingPath: [ CodingKeys . version] , debugDescription: " Invalid value: \( version) " ) )
86
88
}
@@ -94,7 +96,7 @@ struct PackageDataProvider: PackageDataProviding {
94
96
case let . v1( object) :
95
97
return object. pins
96
98
case let . v2( pins) :
97
- return pins
99
+ return pins. convertToV1 ( )
98
100
}
99
101
}
100
102
You can’t perform that action at this time.
0 commit comments