Skip to content

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

Merged
merged 1 commit into from
Oct 5, 2021
Merged

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Oct 5, 2021

motivation: SE-0292 defines that local .netrc files should be honored with priority over user home directory .netrc files

changes:

  • add lookup for local .netrc file before defaulting to user home directory
  • deprecate Workspace.Configuration.Netrc since it now redundant
  • add tests

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
@tomerd
Copy link
Contributor Author

tomerd commented Oct 5, 2021

@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")
Copy link
Contributor Author

@tomerd tomerd Oct 5, 2021

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

Copy link
Contributor

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.

@tomerd tomerd mentioned this pull request Oct 5, 2021
@@ -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 {
Copy link
Contributor

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")
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

@tomerd tomerd merged commit 79dbcff into swiftlang:main Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants