Skip to content

Commit 965c7fe

Browse files
committed
Extract Registry from RegistryConfiguration
1 parent d211961 commit 965c7fe

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

Sources/PackageRegistry/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_library(PackageRegistry
10+
Registry.swift
1011
RegistryConfiguration.swift)
1112
target_link_libraries(PackageRegistry PUBLIC
1213
TSCBasic
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import struct Foundation.URL
12+
13+
public struct Registry: Hashable, Codable {
14+
public var url: Foundation.URL
15+
16+
public init(url: Foundation.URL) {
17+
self.url = url
18+
}
19+
}

Sources/PackageRegistry/RegistryConfiguration.swift

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@ import Foundation
1313
public struct RegistryConfiguration: Hashable {
1414
public typealias Scope = String
1515

16-
public struct Registry: Hashable {
17-
public var url: Foundation.URL
18-
19-
public init(url: Foundation.URL) {
20-
self.url = url
21-
}
22-
}
23-
24-
public enum Version: Int {
16+
public enum Version: Int, Codable {
2517
case v1 = 1
2618
}
2719

@@ -48,6 +40,10 @@ public struct RegistryConfiguration: Hashable {
4840
self.scopedRegistries[scope] = registry
4941
}
5042
}
43+
44+
public func registry(for scope: Scope) -> Registry? {
45+
return scopedRegistries[scope] ?? defaultRegistry
46+
}
5147
}
5248

5349
// MARK: - Codable
@@ -108,6 +104,3 @@ extension RegistryConfiguration: Codable {
108104
}
109105
}
110106
}
111-
112-
extension RegistryConfiguration.Version: Codable {}
113-
extension RegistryConfiguration.Registry: Codable {}

0 commit comments

Comments
 (0)