-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Suggest cargo install --git when missing registry package looks like a git* URL #10522
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
Closed
petr-tik
wants to merge
10
commits into
rust-lang:master
from
petr-tik:n10485_install_from_git_error_message_alternative_impl
Closed
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b87ae28
Fix #10485
petr-tik 174c80e
Refactor select_dep_pkg error handling
petr-tik 869973f
Revert "Refactor select_dep_pkg error handling"
petr-tik e045b4f
Merge remote-tracking branch 'upstream/master' into n10485_install_fr…
petr-tik 1c9c53b
Experiment with GitUrl to generate the suggestion
petr-tik ef7ee2c
Fix the tests
petr-tik e018509
Merge remote-tracking branch 'upstream/master' into n10485_install_fr…
petr-tik 283c6e8
Fix the build and update Cargo.lock
petr-tik ddea258
Replace git-url-parse with gix::url::parse
petr-tik f08e95b
Limit the actionable error to install https inputs
petr-tik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1642,6 +1642,32 @@ fn test_install_git_cannot_be_a_base_url() { | |
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn test_install_from_https_git_generate_suggestion() { | ||
registry::init(); | ||
cargo_process("install https://github.com/rust-lang/cargo") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[UPDATING] `[..]` index | ||
error: could not find `https://github.com/rust-lang/cargo` in registry `crates-io` with version `*`. To install a package from a git repository, use `--git https://github.com/rust-lang/cargo`", | ||
) | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn test_install_from_git_generate_suggestion() { | ||
registry::init(); | ||
cargo_process("install [email protected]:jcmoyer/rust-tictactoe.git") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[UPDATING] `[..]` index | ||
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`", | ||
) | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn uninstall_multiple_and_specifying_bin() { | ||
cargo_process("uninstall foo bar --bin baz") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason this
repo_name = "TODO"
doesn't causetest_install_from_https_git_generate_suggestion
to fail is the same reason whytest_install_from_git_generate_suggestion
is now failing withSince I opened the PR, cargo started supporting
crate@version
command-line arguments2806270
and now the test input
[email protected]:jcmoyer/rust-tictactoe.git
is parsed as a version string (and fails with the error in the CI logs).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.I propose removing this chunk of code and removing the failing test to focus on supporting actionable errors for https git URLs only.
Please let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actioned here
f08e95b