Skip to content

Commit f08e95b

Browse files
committed
Limit the actionable error to install https inputs
Since I opened the PR, cargo started supporting `crate@version` command-line inputs 2806270 and now the test input `[email protected]:jcmoyer/rust-tictactoe.git` is parsed as a version string, which fails the code path I added only deals with strings that weren't erroneously parsed as version strings, so the section I highlighted above won't be traversed, because `git@` strings now fail to parse as version strings before they get here. Delete the failing test
1 parent ddea258 commit f08e95b

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/cargo/ops/common_for_install_and_uninstall.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -541,22 +541,8 @@ fn was_git_url_miscategorised_as_a_registry_dep(dep: &Dependency) -> InstallSugg
541541
if dep.source_id().is_registry() {
542542
if let Ok(git_url) = parse(BStr::new(dep.package_name().as_bytes())) {
543543
let final_git_url: Option<InternedString> = match git_url.scheme {
544-
// cargo doesn't support cargo install git@ urls, so
545-
Scheme::Ssh | Scheme::Git => {
546-
if let (Some(host), Some(owner)) = (git_url.host(), git_url.user()) {
547-
let https_git_url = format!(
548-
"https://{host}/{owner}/{repo_name}",
549-
// repo_name = git_url.name()
550-
repo_name = "TODO"
551-
);
552-
Some(InternedString::from(https_git_url))
553-
} else {
554-
None
555-
}
556-
}
557544
Scheme::Http | Scheme::Https => Some(dep.package_name()),
558-
// otherwise cargo install bar will interpret bar as a file-based
559-
// git repo
545+
// cargo doesn't support cargo install git@ urls
560546
_ => None,
561547
};
562548

tests/testsuite/install.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,19 +1655,6 @@ error: could not find `https://github.com/rust-lang/cargo` in registry `crates-i
16551655
.run();
16561656
}
16571657

1658-
#[cargo_test]
1659-
fn test_install_from_git_generate_suggestion() {
1660-
registry::init();
1661-
cargo_process("install [email protected]:jcmoyer/rust-tictactoe.git")
1662-
.with_status(101)
1663-
.with_stderr(
1664-
"\
1665-
[UPDATING] `[..]` index
1666-
error: could not find `[email protected]:jcmoyer/rust-tictactoe.git` in registry `crates-io` with version `*`. To install a package from a git repository, use `--git https://bitbucket.org/jcmoyer/rust-tictactoe`",
1667-
)
1668-
.run();
1669-
}
1670-
16711658
#[cargo_test]
16721659
fn uninstall_multiple_and_specifying_bin() {
16731660
cargo_process("uninstall foo bar --bin baz")

0 commit comments

Comments
 (0)