Skip to content

Support for gitremote-helpers urls (e.g., transport::opaque-transport-uri) #2076

Open
@demosdemon

Description

@demosdemon

Summary 💡

Gitoxide currently fails to parse the URIs for any remote using a gitremote helper that accepts the second form of remote URI (e.g., git-remote-codecommit).

A URL of the form <transport>::<address> explicitly instructs Git to invoke git remote-<transport> with <address> as the second argument. If such a URL is encountered directly on the command line, the first argument is <address>, and if it is encountered in a configured remote, the first argument is the name of that remote.

Ideally Gitoxide would eventually support invoking one of these helpers (#1666); however, until such time, it would be nice to be able to invoke find_remote and it not bail on parsing the uri.

I can work around this by handling the err as such:

fn repo_info(local_repo: &gix::Repository) -> Result<Info, Error> {
    let default_remote = local_repo
        .remote_default_name(Fetch)
        .ok_or(Error::UnknownDefaultRemoteForFetch)?;
    trace!(?default_remote, "default remote for fetch");

    match local_repo.find_remote(&*default_remote) {
        Ok(remote) => repo_info_for_remote(default_remote, remote),
        Err(Find(Url {
            source:
                KeyError {
                    source: Some(RelativeUrl { url }),
                    ..
                },
            ..
        })) => {
            trace!(
                ?url,
                "found url potentially specifying a remote transport type"
            );

            let Some((transport, url)) = url.split_once("::") else {
                return Err(Error::MissingTransportTypeSeparator {
                    remote_name: default_remote.into_owned(),
                    url: url.to_owned(),
                });
            };

            todo!();
        }
        Err(err) => Err(Error::InvalidRemote {
            remote_name: default_remote.into_owned(),
            source: err,
        }),
    }
}

but then I lose the ability to use the Remote<'_>.


Using try_find_remote_without_url_rewrite does not help as the error from parsing the URL occurs before any rewriting:

let url = match url {
Some(Ok(v)) => Some(v),
Some(Err(err)) => return Some(Err(err)),
None => None,
};
let push_url = match push_url {
Some(Ok(v)) => Some(v),
Some(Err(err)) => return Some(Err(err)),
None => None,
};
let fetch_specs = match fetch_specs {
Some(Ok(v)) => v,
Some(Err(err)) => return Some(Err(err)),
None => Vec::new(),
};
let push_specs = match push_specs {
Some(Ok(v)) => v,
Some(Err(err)) => return Some(Err(err)),
None => Vec::new(),
};

Motivation 🔦

I have a lot of repos using AWS CodeCommit and that service closed to new customers last year prompting me to want to migrate my repos elsewhere. And, I want to use gix in the tooling I write to do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions