Add --global flag to CLI for editing and viewing shared mirrors configuration#9950
Add --global flag to CLI for editing and viewing shared mirrors configuration#9950samuelmurray wants to merge 1 commit into
Conversation
| if !local.isEmpty { | ||
| if let local = try self.localMirrors?.get(), !local.isEmpty { | ||
| try self._mirrors.append(contentsOf: local) | ||
| return |
There was a problem hiding this comment.
Though unrelated to this PR, I'm curious as to why we return here, instead of merging the two configuration files. The code for package registries use both files, merging the information with local configuration having higher priority. https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Workspace/Workspace%2BConfiguration.swift#L732-L738 Is there reason why we don't do it here?
Would it be considered breaking to change mirrors to also merge instead of disregarding the global configuration?
If you have a global configuration with many values, and want to add some override locally, it's a bit inconvenient (and someway unexpected, to me) that you have to duplicate all other global configuration locally.
|
When I ran |
|
@samuelmurray : Thank you very much for the PR. Since this is modifying the SwiftPM command line interface, we should get feedback by the community via the Swift Evolution process. Could you please start the process? |
Formatting/Linting enforcement is tracked under #9397 tracks this, which is currently blocked on swiftlang/swift-format#1156. |
Sure! Would you suggest starting with a pitch, or is this small enough that I can file a proposal PR directly? |
|
I would start with a pitch, can be pretty small. The Build and Package Working Group is still trying to figure out how light weight a process we can put in place to get small changes like this through relatively quickly. |
|
Yes. one step of Swift Evolution proposal is doing a pitch :) |
|
Pitch thread created: https://forums.swift.org/t/pitch-add-cli-to-edit-global-configuration-of-mirrors/86091 |
|
Awesome. Thanks! |
|
Proposal PR filed: swiftlang/swift-evolution#3265 |
Add
--globalflag to CLI for editing and viewing shared mirrors configurationMotivation:
When working with mirrors in SPM, it's sometimes desirable to have a global (per-user) configuration, rather than a local (per-project). Support for a global mirrors configuration file was added in #3670, but no CLI tool was added for editing the global configuration file.
Similar to how the commands for editing the (package) registries configuration file have a
--globalflag, it feels natural that the commands for editing the mirrors configuration file have the same flag.Closes #9947
Modifications:
Add a new flag
--globalto the following commandsswift package config set-mirrorswift package config unset-mirrorswift package config get-mirrorfor interacting with the global mirrors configuration file.
When passing it to
set-mirrororunset-mirror, the global configuration file is modified. When passing it toget-mirror, only the global configuration file is read.Result:
Users can now easily create and maintain a global mirrors configuration file, which was a somewhat hidden feature before.