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

Enable support for arbitrary git transports #8769

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions crates/uv-pep508/src/verbatim_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,20 +413,12 @@ fn split_fragment(path: &Path) -> (Cow<Path>, Option<&str>) {
}

/// A supported URL scheme for PEP 508 direct-URL requirements.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Scheme {
/// `file://...`
File,
/// `git+git://...`
GitGit,
/// `git+http://...`
GitHttp,
/// `git+file://...`
GitFile,
/// `git+ssh://...`
GitSsh,
/// `git+https://...`
GitHttps,
/// `git+{transport}://...` as git supports arbitrary transports through gitremote-helpers
Git(String),
/// `bzr+http://...`
BzrHttp,
/// `bzr+https://...`
Expand Down Expand Up @@ -470,13 +462,11 @@ pub enum Scheme {
impl Scheme {
/// Determine the [`Scheme`] from the given string, if possible.
pub fn parse(s: &str) -> Option<Self> {
if let Some(("git", transport)) = s.split_once('+') {
return Some(Self::Git(transport.into()));
}
match s {
"file" => Some(Self::File),
"git+git" => Some(Self::GitGit),
"git+http" => Some(Self::GitHttp),
"git+file" => Some(Self::GitFile),
"git+ssh" => Some(Self::GitSsh),
"git+https" => Some(Self::GitHttps),
"bzr+http" => Some(Self::BzrHttp),
"bzr+https" => Some(Self::BzrHttps),
"bzr+ssh" => Some(Self::BzrSsh),
Expand Down Expand Up @@ -510,11 +500,7 @@ impl std::fmt::Display for Scheme {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::File => write!(f, "file"),
Self::GitGit => write!(f, "git+git"),
Self::GitHttp => write!(f, "git+http"),
Self::GitFile => write!(f, "git+file"),
Self::GitSsh => write!(f, "git+ssh"),
Self::GitHttps => write!(f, "git+https"),
Self::Git(transport) => write!(f, "git+{transport}"),
Self::BzrHttp => write!(f, "bzr+http"),
Self::BzrHttps => write!(f, "bzr+https"),
Self::BzrSsh => write!(f, "bzr+ssh"),
Expand Down
Loading