-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add support for local netrc file #3790
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
Conversation
motivation: SE-0292 defines that local .etrc files should be honored changes: * add lookup for local .netrc file before defaulting to user hom directory * deprecate Workspace.Configuration.Netrc since it now redundant * add tests
@swift-ci please smoke test |
|
||
return .init(path: defaultPath, fileSystem: localFileSystem) | ||
// TODO: replace multiroot-data-file with explicit overrides | ||
let localPath = try (options.multirootPackageDataFile ?? self.getPackageRoot()).appending(component: ".netrc") |
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.
@mattt not sure what location you had in mind for the local case. for this PR I assumed the package's root directory (ie <root>/.netrc
), but we can consider other locations like <root>/.swiftpm/configuration/.netrc
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.
That's perfect. I think <root>/.netrc
is the right place to look for a local override.
As for .swiftpm/configuration
, I think that makes more sense for configuration that's specific to Swift Package Manager. Since .netrc
files are a de facto standard, I wouldn't expect to see them there.
@@ -129,4 +129,8 @@ extension FileSystem { | |||
public func writeFileContents(_ path: AbsolutePath, string: String) throws { | |||
return try self.writeFileContents(path, bytes: .init(encodingAsUTF8: string)) | |||
} | |||
|
|||
public func writeFileContents(_ path: AbsolutePath, provider: () -> String) throws { |
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.
Could we consolidate this into the existing API by changing the original signature to use an @autoclosure
?
|
||
return .init(path: defaultPath, fileSystem: localFileSystem) | ||
// TODO: replace multiroot-data-file with explicit overrides | ||
let localPath = try (options.multirootPackageDataFile ?? self.getPackageRoot()).appending(component: ".netrc") |
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.
That's perfect. I think <root>/.netrc
is the right place to look for a local override.
As for .swiftpm/configuration
, I think that makes more sense for configuration that's specific to Swift Package Manager. Since .netrc
files are a de facto standard, I wouldn't expect to see them there.
import XCTest | ||
|
||
final class SwiftToolTests: XCTestCase { | ||
func testNetrcLocations() throws { |
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.
🤩
motivation: SE-0292 defines that local .netrc files should be honored with priority over user home directory .netrc files
changes: