-
Notifications
You must be signed in to change notification settings - Fork 1.4k
api cleanup in preperation for identity improvements #3214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,35 +24,35 @@ import TSCUtility | |
/// should be used as-is. Infact, they might not even have a git repository. | ||
/// Examples: Root packages, local dependencies, edited packages. | ||
public final class LocalPackageContainer: PackageContainer { | ||
public let identifier: PackageReference | ||
public let package: PackageReference | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we call this |
||
private let mirrors: DependencyMirrors | ||
private let manifestLoader: ManifestLoaderProtocol | ||
private let toolsVersionLoader: ToolsVersionLoaderProtocol | ||
private let currentToolsVersion: ToolsVersion | ||
|
||
/// The file system that shoud be used to load this package. | ||
private let fs: FileSystem | ||
private let fileSystem: FileSystem | ||
|
||
/// cached version of the manifest | ||
private let manifest = ThreadSafeBox<Manifest>() | ||
|
||
private func loadManifest() throws -> Manifest { | ||
try manifest.memoize() { | ||
// Load the tools version. | ||
let toolsVersion = try toolsVersionLoader.load(at: AbsolutePath(identifier.path), fileSystem: fs) | ||
let toolsVersion = try toolsVersionLoader.load(at: AbsolutePath(package.location), fileSystem: fileSystem) | ||
|
||
// Validate the tools version. | ||
try toolsVersion.validateToolsVersion(self.currentToolsVersion, packagePath: identifier.path) | ||
try toolsVersion.validateToolsVersion(self.currentToolsVersion, packagePath: package.location) | ||
|
||
// Load the manifest. | ||
// FIXME: this should not block | ||
return try temp_await { | ||
manifestLoader.load(package: AbsolutePath(identifier.path), | ||
baseURL: identifier.path, | ||
manifestLoader.load(package: AbsolutePath(package.location), | ||
baseURL: package.location, | ||
version: nil, | ||
toolsVersion: toolsVersion, | ||
packageKind: identifier.kind, | ||
fileSystem: fs, | ||
packageKind: package.kind, | ||
fileSystem: fileSystem, | ||
on: .global(), | ||
completion: $0) | ||
} | ||
|
@@ -66,24 +66,24 @@ public final class LocalPackageContainer: PackageContainer { | |
public func getUpdatedIdentifier(at boundVersion: BoundVersion) throws -> PackageReference { | ||
assert(boundVersion == .unversioned, "Unexpected bound version \(boundVersion)") | ||
let manifest = try loadManifest() | ||
return identifier.with(newName: manifest.name) | ||
return package.with(newName: manifest.name) | ||
} | ||
|
||
public init( | ||
_ identifier: PackageReference, | ||
package: PackageReference, | ||
mirrors: DependencyMirrors, | ||
manifestLoader: ManifestLoaderProtocol, | ||
toolsVersionLoader: ToolsVersionLoaderProtocol, | ||
currentToolsVersion: ToolsVersion, | ||
fs: FileSystem = localFileSystem | ||
fileSystem: FileSystem = localFileSystem | ||
) { | ||
assert(URL.scheme(identifier.path) == nil, "unexpected scheme \(URL.scheme(identifier.path)!) in \(identifier.path)") | ||
self.identifier = identifier | ||
assert(URL.scheme(package.location) == nil, "unexpected scheme \(URL.scheme(package.location)!) in \(package.location)") | ||
self.package = package | ||
self.mirrors = mirrors | ||
self.manifestLoader = manifestLoader | ||
self.toolsVersionLoader = toolsVersionLoader | ||
self.currentToolsVersion = currentToolsVersion | ||
self.fs = fs | ||
self.fileSystem = fileSystem | ||
} | ||
|
||
public func isToolsVersionCompatible(at version: Version) -> Bool { | ||
|
@@ -113,6 +113,6 @@ public final class LocalPackageContainer: PackageContainer { | |
|
||
extension LocalPackageContainer: CustomStringConvertible { | ||
public var description: String { | ||
return "LocalPackageContainer(\(identifier.path))" | ||
return "LocalPackageContainer(\(package.location))" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this
packageReference
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neonichu we could, but in many other places in the code vase it is called "package". I actually have a commit with this change but its large if we want to be consistent. wdyt?