Skip to content

Commit 4cd8482

Browse files
committed
fixup
1 parent e412c26 commit 4cd8482

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

Sources/Basics/SourceControlURL.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@
1313
import Foundation
1414

1515
public struct SourceControlURL: Codable, Equatable, Hashable, Sendable {
16-
private let underlying: URL?
1716
private let urlString: String
1817

1918
public init(stringLiteral: String) {
20-
self.underlying = URL(string: stringLiteral)
2119
self.urlString = stringLiteral
2220
}
2321

2422
public init(_ urlString: String) {
25-
self.underlying = URL(string: urlString)
2623
self.urlString = urlString
2724
}
2825

2926
public init(_ url: URL) {
30-
self.underlying = url
3127
self.urlString = url.absoluteString
3228
}
3329

@@ -40,11 +36,7 @@ public struct SourceControlURL: Codable, Equatable, Hashable, Sendable {
4036
}
4137

4238
public var url: URL? {
43-
return self.underlying
44-
}
45-
46-
public var scheme: String? {
47-
return self.underlying?.scheme
39+
return URL(string: self.absoluteString)
4840
}
4941
}
5042

Sources/PackageModel/PackageIdentity.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public struct CanonicalPackageLocation: Equatable, CustomStringConvertible {
424424
}
425425

426426
/// Similar to `CanonicalPackageLocation` but differentiates based on the scheme.
427-
public struct CanonicalPackageURL: CustomStringConvertible {
427+
public struct CanonicalPackageURL: Equatable, CustomStringConvertible {
428428
public let description: String
429429
public let scheme: String?
430430

Sources/PackageModel/PackageReference.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,16 @@ extension PackageReference: Equatable {
169169
}
170170
switch (self.kind, other.kind) {
171171
case (.remoteSourceControl(let lurl), .remoteSourceControl(let rurl)):
172-
return lurl.scheme == rurl.scheme
172+
return lurl.canonicalURL == rurl.canonicalURL
173173
default:
174-
break
174+
return true
175175
}
176-
return true
176+
}
177+
}
178+
179+
extension SourceControlURL {
180+
var canonicalURL: CanonicalPackageURL {
181+
CanonicalPackageURL(self.absoluteString)
177182
}
178183
}
179184

Tests/WorkspaceTests/WorkspaceTests.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11367,7 +11367,8 @@ final class WorkspaceTests: XCTestCase {
1136711367
products: [
1136811368
MockProduct(name: "FooProduct", targets: ["FooTarget"]),
1136911369
],
11370-
versions: ["1.0.0"]
11370+
versions: ["1.0.0"],
11371+
revisionProvider: { _ in "foo" } // we need this to be consistent for fingerprints check to work
1137111372
),
1137211373
MockPackage(
1137311374
name: "FooPackage",
@@ -11378,7 +11379,8 @@ final class WorkspaceTests: XCTestCase {
1137811379
products: [
1137911380
MockProduct(name: "FooProduct", targets: ["FooTarget"]),
1138011381
],
11381-
versions: ["1.0.0"]
11382+
versions: ["1.0.0"],
11383+
revisionProvider: { _ in "foo" } // we need this to be consistent for fingerprints check to work
1138211384
),
1138311385
]
1138411386
)
@@ -11480,7 +11482,8 @@ final class WorkspaceTests: XCTestCase {
1148011482
products: [
1148111483
MockProduct(name: "FooProduct", targets: ["FooTarget"]),
1148211484
],
11483-
versions: ["1.0.0"]
11485+
versions: ["1.0.0"],
11486+
revisionProvider: { _ in "foo" } // we need this to be consistent for fingerprints check to work
1148411487
),
1148511488
MockPackage(
1148611489
name: "BarPackage",
@@ -11510,7 +11513,8 @@ final class WorkspaceTests: XCTestCase {
1151011513
products: [
1151111514
MockProduct(name: "FooProduct", targets: ["FooTarget"]),
1151211515
],
11513-
versions: ["1.0.0"]
11516+
versions: ["1.0.0"],
11517+
revisionProvider: { _ in "foo" } // we need this to be consistent for fingerprints check to work
1151411518
),
1151511519
MockPackage(
1151611520
name: "FooPackage",
@@ -11521,7 +11525,8 @@ final class WorkspaceTests: XCTestCase {
1152111525
products: [
1152211526
MockProduct(name: "FooProduct", targets: ["FooTarget"]),
1152311527
],
11524-
versions: ["1.0.0"]
11528+
versions: ["1.0.0"],
11529+
revisionProvider: { _ in "foo" } // we need this to be consistent for fingerprints check to work
1152511530
),
1152611531
]
1152711532
)

0 commit comments

Comments
 (0)