Skip to content
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

fix: normalize relative git submodule urls with ssh:// #12411

Merged
merged 1 commit into from
Jul 30, 2023

Commits on Jul 30, 2023

  1. fix: normalize relative git submodule urls with ssh://

    Git only assumes a submodule URL is a relative path if it starts with `./`
    or `../` [^1]. To fetch the correct repo, we need to construct an aboslute
    submodule URL.
    
    At this moment it comes with some limitations:
    
    * GitHub doesn't accept non-normalized URLs wth relative paths.
      (`ssh://git@github.com/rust-lang/cargo.git/relative/..` is invalid)
    * `url` crate cannot parse SCP-like URLs.
      (`git@github.com:rust-lang/cargo.git` is not a valid WHATWG URL)
    
    To overcome these, this patch always tries `Url::parse` first to normalize
    the path. If it couldn't, append the relative path as the last resort and
    pray the remote git service supports non-normalized URLs.
    
    See also rust-lang#12404 and rust-lang#12295.
    
    [^1]: <https://git-scm.com/docs/git-submodule>
    weihanglo authored and ehuss committed Jul 30, 2023
    Configuration menu
    Copy the full SHA
    8a4d044 View commit details
    Browse the repository at this point in the history