File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,11 @@ public final class ManagedDependencies: SimplePersistanceProtocol {
276
276
try self . persistence. saveState ( self )
277
277
}
278
278
279
+ /// Returns true if the state file exists on the filesystem.
280
+ public func stateFileExists( ) -> Bool {
281
+ return persistence. stateFileExists ( )
282
+ }
283
+
279
284
public var values : AnySequence < ManagedDependency > {
280
285
return AnySequence < ManagedDependency > ( dependencyMap. values)
281
286
}
Original file line number Diff line number Diff line change @@ -1589,6 +1589,12 @@ extension Workspace {
1589
1589
/// If some edited dependency is removed from the file system, mark it as unedited and
1590
1590
/// fallback on the original checkout.
1591
1591
fileprivate func fixManagedDependencies( with diagnostics: DiagnosticsEngine ) {
1592
+
1593
+ // Reset managed dependencies if the state file was removed during the lifetime of the Workspace object.
1594
+ if managedDependencies. values. contains ( where: { _ in true } ) && !managedDependencies. stateFileExists ( ) {
1595
+ try ? managedDependencies. reset ( )
1596
+ }
1597
+
1592
1598
for dependency in managedDependencies. values {
1593
1599
diagnostics. wrap {
1594
1600
Original file line number Diff line number Diff line change @@ -97,6 +97,14 @@ final class WorkspaceTests: XCTestCase {
97
97
result. check ( dependency: " quix " , at: . checkout( . version( " 1.2.0 " ) ) )
98
98
}
99
99
100
+ let stateFile = workspace. createWorkspace ( ) . managedDependencies. statePath
101
+
102
+ // Remove state file and check we can get the state back automatically.
103
+ try fs. removeFileTree ( stateFile)
104
+
105
+ workspace. checkPackageGraph ( roots: [ " Foo " ] , deps: deps) { _, _ in }
106
+ XCTAssertTrue ( fs. exists ( stateFile) )
107
+
100
108
// Remove state file and check we get back to a clean state.
101
109
try fs. removeFileTree ( workspace. createWorkspace ( ) . managedDependencies. statePath)
102
110
workspace. closeWorkspace ( )
You can’t perform that action at this time.
0 commit comments