@@ -27,10 +27,10 @@ extension Workspace {
27
27
case fileSystem( AbsolutePath )
28
28
29
29
/// The dependency is a managed source control checkout.
30
- case sourceControl ( CheckoutState )
30
+ case sourceControlCheckout ( CheckoutState )
31
31
32
32
/// The dependency is downloaded from a registry.
33
- case registry ( version: Version )
33
+ case registryDownload ( version: Version )
34
34
35
35
/// The dependency is in edited state.
36
36
///
@@ -43,10 +43,10 @@ extension Workspace {
43
43
switch self {
44
44
case . fileSystem( let path) :
45
45
return " fileSystem ( \( path) ) "
46
- case . sourceControl ( let checkoutState) :
47
- return " sourceControl (\( checkoutState) ) "
48
- case . registry ( let version) :
49
- return " registry (\( version) ) "
46
+ case . sourceControlCheckout ( let checkoutState) :
47
+ return " sourceControlCheckout (\( checkoutState) ) "
48
+ case . registryDownload ( let version) :
49
+ return " registryDownload (\( version) ) "
50
50
case . edited:
51
51
return " edited "
52
52
}
@@ -78,8 +78,15 @@ extension Workspace {
78
78
/// - Parameters:
79
79
/// - subpath: The subpath inside the editable directory.
80
80
/// - unmanagedPath: A custom absolute path instead of the subpath.
81
- public func edited( subpath: RelativePath , unmanagedPath: AbsolutePath ? ) -> ManagedDependency {
82
- return . edited( packageRef: self . packageRef, subpath: subpath, basedOn: self , unmanagedPath: unmanagedPath)
81
+ public func edited( subpath: RelativePath , unmanagedPath: AbsolutePath ? ) throws -> ManagedDependency {
82
+ guard case . sourceControlCheckout = self . state else {
83
+ throw InternalError ( " invalid depenedency state: \( self . state) " )
84
+ }
85
+ return ManagedDependency (
86
+ packageRef: self . packageRef,
87
+ state: . edited( basedOn: self , unmanagedPath: unmanagedPath) ,
88
+ subpath: subpath
89
+ )
83
90
}
84
91
85
92
/// Create a dependency present locally on the filesystem.
@@ -100,7 +107,7 @@ extension Workspace {
100
107
}
101
108
102
109
/// Create a source control dependency checked out
103
- public static func sourceControl (
110
+ public static func sourceControlCheckout (
104
111
packageRef: PackageReference ,
105
112
state: CheckoutState ,
106
113
subpath: RelativePath
@@ -109,16 +116,16 @@ extension Workspace {
109
116
case . localSourceControl, . remoteSourceControl:
110
117
return ManagedDependency (
111
118
packageRef: packageRef,
112
- state: . sourceControl ( state) ,
119
+ state: . sourceControlCheckout ( state) ,
113
120
subpath: subpath
114
121
)
115
122
default :
116
123
throw InternalError ( " invalid package type: \( packageRef. kind) " )
117
124
}
118
125
}
119
126
120
- /// Create a registry dependency downloaded
121
- public static func registry (
127
+ /// Create a registry dependency downloaded
128
+ public static func registryDownload (
122
129
packageRef: PackageReference ,
123
130
version: Version ,
124
131
subpath: RelativePath
@@ -128,7 +135,7 @@ extension Workspace {
128
135
}
129
136
return ManagedDependency (
130
137
packageRef: packageRef,
131
- state: . registry ( version: version) ,
138
+ state: . registryDownload ( version: version) ,
132
139
subpath: subpath
133
140
)
134
141
}
@@ -166,7 +173,7 @@ extension Workspace {
166
173
init ( _ dependencies: [ ManagedDependency ] = [ ] ) {
167
174
self . dependencies = Dictionary ( uniqueKeysWithValues: dependencies. map { ( $0. packageRef. identity, $0) } )
168
175
}
169
-
176
+
170
177
public subscript( identity: PackageIdentity ) -> ManagedDependency ? {
171
178
return self . dependencies [ identity]
172
179
}
0 commit comments