mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
add Url::parse
context
This commit is contained in:
parent
4f5ac2a20f
commit
f07753deda
@ -444,25 +444,31 @@ impl<'a> GitCheckout<'a> {
|
||||
// See [`git submodule add`] documentation.
|
||||
//
|
||||
// [`git submodule add`]: https://git-scm.com/docs/git-submodule
|
||||
let child_remote_url =
|
||||
if child_url_str.starts_with("./") || child_url_str.starts_with("../") {
|
||||
let mut new_parent_remote_url = parent_remote_url.clone();
|
||||
let child_remote_url = if child_url_str.starts_with("./")
|
||||
|| child_url_str.starts_with("../")
|
||||
{
|
||||
let mut new_parent_remote_url = parent_remote_url.clone();
|
||||
|
||||
let mut new_path = Cow::from(parent_remote_url.path());
|
||||
if !new_path.ends_with('/') {
|
||||
new_path.to_mut().push('/');
|
||||
}
|
||||
new_parent_remote_url.set_path(&new_path);
|
||||
let mut new_path = Cow::from(parent_remote_url.path());
|
||||
if !new_path.ends_with('/') {
|
||||
new_path.to_mut().push('/');
|
||||
}
|
||||
new_parent_remote_url.set_path(&new_path);
|
||||
|
||||
new_parent_remote_url.join(child_url_str).with_context(|| {
|
||||
format!(
|
||||
"failed to parse relative child submodule url `{child_url_str}` \
|
||||
new_parent_remote_url.join(child_url_str).with_context(|| {
|
||||
format!(
|
||||
"failed to parse relative child submodule url `{child_url_str}` \
|
||||
using parent base url `{new_parent_remote_url}`"
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
Url::parse(child_url_str).with_context(|| {
|
||||
let child_module_name = child.name().unwrap_or("");
|
||||
format!(
|
||||
"failed to parse url for submodule `{child_module_name}`: `{child_url_str}`"
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
Url::parse(child_url_str)?
|
||||
};
|
||||
};
|
||||
|
||||
// A submodule which is listed in .gitmodules but not actually
|
||||
// checked out will not have a head id, so we should ignore it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user