Description
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 invokegit 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:
gitoxide/gix/src/repository/remote.rs
Lines 190 to 209 in c7af04d
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.