Skip to content

Commit 56f6939

Browse files
committed
fixup
1 parent d18dc91 commit 56f6939

File tree

7 files changed

+46
-38
lines changed

7 files changed

+46
-38
lines changed

Sources/Commands/APIDigester.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ struct APIDigesterBaselineDumper {
4949
self.baselineRevision = baselineRevision
5050
self.packageRoot = packageRoot
5151
self.inputBuildParameters = buildParameters
52-
//self.manifestLoader = manifestLoader
53-
//self.repositoryManager = repositoryManager
5452
self.apiDigesterTool = apiDigesterTool
5553
self.diags = diags
5654
}

Sources/Commands/SwiftTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ public class SwiftTool {
556556
location: .init(
557557
workingDirectory: buildPath,
558558
editsDirectory: try editablesPath(),
559-
resolvedVersionsFilePath: try resolvedVersionsFilePath()
559+
resolvedVersionsFilePath: try resolvedVersionsFilePath(),
560+
sharedCacheDirectory: cachePath
560561
),
561-
cachePath: cachePath,
562562
netrcFilePath: try netrcFilePath(),
563563
mirrors: self.getMirrorsConfig().mirrors,
564564
customManifestLoader: try getManifestLoader(), // FIXME: doe we really need to customize it?

Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public struct PubgrubDependencyResolver {
108108
/// Should resolver prefetch the containers.
109109
private let prefetchingEnabled: Bool
110110

111-
/// Skip updating containers while fetching them.
111+
/// Update containers while fetching them.
112112
private let updateEnabled: Bool
113113

114114
/// Resolver delegate

Sources/SPMTestSupport/MockWorkspace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public final class MockWorkspace {
161161
location: .init (
162162
workingDirectory: self.sandbox.appending(component: ".build"),
163163
editsDirectory: self.sandbox.appending(component: "edits"),
164-
resolvedVersionsFilePath: self.sandbox.appending(component: "Package.resolved")
164+
resolvedVersionsFilePath: self.sandbox.appending(component: "Package.resolved"),
165+
sharedCacheDirectory: self.fs.swiftPMCacheDirectory
165166
),
166-
cachePath: self.fs.swiftPMCacheDirectory,
167167
mirrors: self.config.mirrors,
168168
customToolsVersion: self.toolsVersion,
169169
customManifestLoader: self.manifestLoader,

Sources/Workspace/Workspace.swift

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public class Workspace {
211211
/// Enable prefetching containers in resolver.
212212
fileprivate let resolverPrefetchingEnabled: Bool
213213

214-
/// Skip updating containers while fetching them.
214+
/// Update containers while fetching them.
215215
fileprivate let resolverUpdateEnabled: Bool
216216

217217
/// Write dependency resolver trace to a file.
@@ -238,9 +238,6 @@ public class Workspace {
238238
/// - Parameters:
239239
/// - fileSystem: The file system to use.
240240
/// - location: Workspace location configuration.
241-
/// - editablesPath: Path to store the editable versions of dependencies.
242-
/// - resolvedVersionsFilePath: Path to the Package.resolved file.
243-
/// - cachePath: Path to the shared cache.
244241
/// - netrcFilePath: Path tot he netrc file.
245242
/// - mirrors: Dependencies mirrors.
246243
/// - customToolsVersion: A custom tools version.
@@ -259,7 +256,6 @@ public class Workspace {
259256
public init(
260257
fileSystem: FileSystem,
261258
location: Location,
262-
cachePath: AbsolutePath? = .none,
263259
netrcFilePath: AbsolutePath? = .none,
264260
mirrors: DependencyMirrors? = .none,
265261
customToolsVersion: ToolsVersion? = .none,
@@ -281,14 +277,12 @@ public class Workspace {
281277
let toolsVersionLoader = ToolsVersionLoader()
282278
let manifestLoader = try customManifestLoader ?? ManifestLoader(toolchain: UserToolchain(destination: .hostDestination()).configuration)
283279
let repositoryProvider = customRepositoryProvider ?? GitRepositoryProvider()
284-
let repositoriesPath = location.workingDirectory.appending(component: "repositories")
285-
let repositoriesCachePath = cachePath.map { $0.appending(component: "repositories") }
286280
let repositoryManager = customRepositoryManager ?? RepositoryManager(
287-
path: repositoriesPath,
281+
path: location.repositoriesDirectory,
288282
provider: repositoryProvider,
289283
delegate: delegate.map(WorkspaceRepositoryManagerDelegate.init(workspaceDelegate:)),
290284
fileSystem: fileSystem,
291-
cachePath: repositoriesCachePath)
285+
cachePath: location.repositoriesSharedCacheDirectory)
292286
let httpClient = customHTTPClient ?? HTTPClient()
293287
let archiver = customArchiver ?? ZipArchiver()
294288
let mirrors = mirrors ?? DependencyMirrors()
@@ -374,9 +368,9 @@ public class Workspace {
374368
location: .init(
375369
workingDirectory: dataPath,
376370
editsDirectory: editablesPath,
377-
resolvedVersionsFilePath: pinsFile
371+
resolvedVersionsFilePath: pinsFile,
372+
sharedCacheDirectory: cachePath
378373
),
379-
cachePath: cachePath,
380374
netrcFilePath: netrcFilePath,
381375
mirrors: config?.mirrors,
382376
customToolsVersion: currentToolsVersion,
@@ -602,7 +596,7 @@ extension Workspace {
602596
// These are the things we don't want to remove while cleaning.
603597
let protectedAssets = [
604598
repositoryManager.path,
605-
self.location.checkoutsDirectory,
599+
self.location.repositoriesCheckoutsDirectory,
606600
self.location.artifactsDirectory,
607601
state.path,
608602
].map({ path -> String in
@@ -646,7 +640,7 @@ extension Workspace {
646640
/// and notes.
647641
public func reset(with diagnostics: DiagnosticsEngine) {
648642
let removed = diagnostics.wrap {
649-
try fileSystem.chmod(.userWritable, path: self.location.checkoutsDirectory, options: [.recursive, .onlyFiles])
643+
try fileSystem.chmod(.userWritable, path: self.location.repositoriesCheckoutsDirectory, options: [.recursive, .onlyFiles])
650644
// Reset state.
651645
try self.resetState()
652646
}
@@ -1072,7 +1066,7 @@ extension Workspace {
10721066

10731067
// Remove the existing checkout.
10741068
do {
1075-
let oldCheckoutPath = self.location.checkoutsDirectory.appending(dependency.subpath)
1069+
let oldCheckoutPath = self.location.repositoriesCheckoutsDirectory.appending(dependency.subpath)
10761070
try fileSystem.chmod(.userWritable, path: oldCheckoutPath, options: [.recursive, .onlyFiles])
10771071
try fileSystem.removeFileTree(oldCheckoutPath)
10781072
}
@@ -1370,7 +1364,7 @@ extension Workspace {
13701364
fileprivate func createCacheDirectories(with diagnostics: DiagnosticsEngine) {
13711365
do {
13721366
try fileSystem.createDirectory(repositoryManager.path, recursive: true)
1373-
try fileSystem.createDirectory(self.location.checkoutsDirectory, recursive: true)
1367+
try fileSystem.createDirectory(self.location.repositoriesCheckoutsDirectory, recursive: true)
13741368
try fileSystem.createDirectory(self.location.artifactsDirectory, recursive: true)
13751369
} catch {
13761370
diagnostics.emit(error)
@@ -1385,7 +1379,7 @@ extension Workspace {
13851379
public func path(to dependency: ManagedDependency) -> AbsolutePath {
13861380
switch dependency.state {
13871381
case .checkout:
1388-
return self.location.checkoutsDirectory.appending(dependency.subpath)
1382+
return self.location.repositoriesCheckoutsDirectory.appending(dependency.subpath)
13891383
case .edited(let path):
13901384
return path ?? self.location.editsDirectory.appending(dependency.subpath)
13911385
case .local:
@@ -2620,7 +2614,7 @@ extension Workspace {
26202614
private func fetch(package: PackageReference) throws -> AbsolutePath {
26212615
// If we already have it, fetch to update the repo from its remote.
26222616
if let dependency = state.dependencies[forURL: package.location] {
2623-
let path = self.location.checkoutsDirectory.appending(dependency.subpath)
2617+
let path = self.location.repositoriesCheckoutsDirectory.appending(dependency.subpath)
26242618

26252619
// Make sure the directory is not missing (we will have to clone again
26262620
// if not).
@@ -2652,7 +2646,7 @@ extension Workspace {
26522646
}
26532647

26542648
// Clone the repository into the checkouts.
2655-
let path = self.location.checkoutsDirectory.appending(component: package.repository.basename)
2649+
let path = self.location.repositoriesCheckoutsDirectory.appending(component: package.repository.basename)
26562650

26572651
try fileSystem.chmod(.userWritable, path: path, options: [.recursive, .onlyFiles])
26582652
try fileSystem.removeFileTree(path)
@@ -2696,7 +2690,7 @@ extension Workspace {
26962690
// Write the state record.
26972691
state.dependencies.add(ManagedDependency(
26982692
packageRef: package,
2699-
subpath: path.relative(to: self.location.checkoutsDirectory),
2693+
subpath: path.relative(to: self.location.repositoriesCheckoutsDirectory),
27002694
checkoutState: checkoutState))
27012695
try state.saveState()
27022696

@@ -2779,7 +2773,7 @@ extension Workspace {
27792773
}
27802774

27812775
// Remove the checkout.
2782-
let dependencyPath = self.location.checkoutsDirectory.appending(dependencyToRemove.subpath)
2776+
let dependencyPath = self.location.repositoriesCheckoutsDirectory.appending(dependencyToRemove.subpath)
27832777
let workingCopy = try repositoryManager.provider.openWorkingCopy(at: dependencyPath)
27842778
guard !workingCopy.hasUncommittedChanges() else {
27852779
throw WorkspaceDiagnostics.UncommitedChanges(repositoryPath: dependencyPath)

Sources/Workspace/WorkspaceConfiguration.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,25 @@ extension Workspace {
2727
/// Path to the Package.resolved file.
2828
public var resolvedVersionsFilePath: AbsolutePath
2929

30-
/// Path to working repository clones (checkouts).
31-
public var checkoutsDirectory: AbsolutePath {
30+
/// Path to the shared cache
31+
public var sharedCacheDirectory: AbsolutePath?
32+
33+
/// Path to the repositories shared cache.
34+
public var repositoriesSharedCacheDirectory: AbsolutePath? {
35+
self.sharedCacheDirectory.map { $0.appending(component: "repositories") }
36+
}
37+
38+
/// Path to the repositories clones.
39+
public var repositoriesDirectory: AbsolutePath {
40+
self.workingDirectory.appending(component: "repositories")
41+
}
42+
43+
/// Path to the repository checkouts.
44+
public var repositoriesCheckoutsDirectory: AbsolutePath {
3245
self.workingDirectory.appending(component: "checkouts")
3346
}
3447

35-
// Path for downloaded binary artifacts.
48+
/// Path to the downloaded binary artifacts.
3649
public var artifactsDirectory: AbsolutePath {
3750
self.workingDirectory.appending(component: "artifacts")
3851
}
@@ -43,14 +56,17 @@ extension Workspace {
4356
/// - workingDirectory: Path to working directory for this workspace.
4457
/// - editsDirectory: Path to store the editable versions of dependencies.
4558
/// - resolvedVersionsFile: Path to the Package.resolved file.
59+
/// - sharedCachePath: Path to the sharedCache
4660
public init(
4761
workingDirectory: AbsolutePath,
4862
editsDirectory: AbsolutePath,
49-
resolvedVersionsFilePath: AbsolutePath)
50-
{
63+
resolvedVersionsFilePath: AbsolutePath,
64+
sharedCacheDirectory: AbsolutePath? = .none
65+
) {
5166
self.workingDirectory = workingDirectory
5267
self.editsDirectory = editsDirectory
5368
self.resolvedVersionsFilePath = resolvedVersionsFilePath
69+
self.sharedCacheDirectory = sharedCacheDirectory
5470
}
5571

5672
/// Create a new workspace location.

Tests/WorkspaceTests/WorkspaceTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ final class WorkspaceTests: XCTestCase {
141141
location: .init(
142142
workingDirectory: sandbox.appending(component: ".build"),
143143
editsDirectory: sandbox.appending(component: "edits"),
144-
resolvedVersionsFilePath: sandbox.appending(component: "Package.resolved")
144+
resolvedVersionsFilePath: sandbox.appending(component: "Package.resolved"),
145+
sharedCacheDirectory: fs.swiftPMCacheDirectory.appending(component: "repositories")
145146
),
146-
cachePath: fs.swiftPMCacheDirectory.appending(component: "repositories"),
147147
customManifestLoader: manifestLoader,
148148
delegate: MockWorkspaceDelegate()
149149
)
@@ -1706,13 +1706,13 @@ final class WorkspaceTests: XCTestCase {
17061706

17071707
// Sanity checks.
17081708
XCTAssert(fs.exists(buildArtifact))
1709-
XCTAssert(fs.exists(ws.location.checkoutsDirectory))
1709+
XCTAssert(fs.exists(ws.location.repositoriesCheckoutsDirectory))
17101710

17111711
// Check clean.
17121712
workspace.checkClean { diagnostics in
17131713
// Only the build artifact should be removed.
17141714
XCTAssertFalse(fs.exists(buildArtifact))
1715-
XCTAssert(fs.exists(ws.location.checkoutsDirectory))
1715+
XCTAssert(fs.exists(ws.location.repositoriesCheckoutsDirectory))
17161716
XCTAssert(fs.exists(ws.location.workingDirectory))
17171717

17181718
XCTAssertNoDiagnostics(diagnostics)
@@ -1728,7 +1728,7 @@ final class WorkspaceTests: XCTestCase {
17281728
workspace.checkReset { diagnostics in
17291729
// Only the build artifact should be removed.
17301730
XCTAssertFalse(fs.exists(buildArtifact))
1731-
XCTAssertFalse(fs.exists(ws.location.checkoutsDirectory))
1731+
XCTAssertFalse(fs.exists(ws.location.repositoriesCheckoutsDirectory))
17321732
XCTAssertFalse(fs.exists(ws.location.workingDirectory))
17331733

17341734
XCTAssertNoDiagnostics(diagnostics)
@@ -2044,7 +2044,7 @@ final class WorkspaceTests: XCTestCase {
20442044
XCTAssertNoDiagnostics(diagnostics)
20452045
}
20462046

2047-
try fs.removeFileTree(workspace.getOrCreateWorkspace().location.checkoutsDirectory)
2047+
try fs.removeFileTree(workspace.getOrCreateWorkspace().location.repositoriesCheckoutsDirectory)
20482048

20492049
workspace.checkPackageGraph(roots: ["Root"]) { graph, diagnostics in
20502050
PackageGraphTester(graph) { result in

0 commit comments

Comments
 (0)