mirror of
https://github.com/apple/swift.git
synced 2026-09-28 10:03:29 +02:00
A repository in an update-checkout config can override the URL that would otherwise be interpolated from the top-level ssh/https clone patterns by specifying a "url" in its "remote" object. That override applies to both protocols, so a downstream config that needs to point a repository at a different host than the rest of its repositories has to pick one protocol for it and force everyone onto that protocol, regardless of whether --clone-with-ssh was passed. In practice this means such repositories end up pinned to ssh URLs even for users cloning over https. Add two new optional keys to a repository's "remote" object, "ssh-url" and "https-url", so an override can be specified per protocol. The URL selection now goes: the override matching the requested protocol, then the protocol-agnostic "url", then the override for the other protocol, and finally the URL interpolated from the matching clone pattern and the remote "id". An override is preferred over interpolation even when it does not match the requested protocol, since it is the more specific piece of configuration; a repository that only specifies "https-url" is therefore still cloned over https under --clone-with-ssh. Existing configurations are unaffected: a "remote" with only a "url" continues to use it for both protocols. While here, factor the URL computation out of obtain_all_additional_swift_sources into remote_url_for_repo so it can be unit tested, and diagnose a "remote" that specifies none of the recognized keys instead of failing with a KeyError.