Skip to content

Commit 85fa08a

Browse files
committed
Fix .netrc file handling behavior
Don't emit error if .netrc file isn't found in default location
1 parent f219f4f commit 85fa08a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Sources/Commands/SwiftTool.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,18 @@ public class SwiftTool {
488488
func getNetrcConfig() -> Workspace.Configuration.Netrc? {
489489
guard options.netrc else { return nil }
490490

491-
let path = options.netrcFilePath ?? localFileSystem.homeDirectory.appending(component: ".netrc")
492-
guard localFileSystem.exists(path) else {
493-
ObservabilitySystem.topScope.emit(warning: "Did not find .netrc file at \(path).")
494-
return nil
495-
}
491+
if let configuredPath = options.netrcFilePath {
492+
guard localFileSystem.exists(configuredPath) else {
493+
ObservabilitySystem.topScope.emit(warning: "Did not find .netrc file at \(configuredPath).")
494+
return nil
495+
}
496496

497-
return .init(path: path, fileSystem: localFileSystem)
497+
return .init(path: configuredPath, fileSystem: localFileSystem)
498+
} else {
499+
let defaultPath = localFileSystem.homeDirectory.appending(component: ".netrc")
500+
501+
return .init(path: defaultPath, fileSystem: localFileSystem)
502+
}
498503
}
499504

500505
private func getSharedCacheDirectory() throws -> AbsolutePath? {

0 commit comments

Comments
 (0)