-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(install): check if git url contains a rev #15489
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
base: master
Are you sure you want to change the base?
Conversation
src/bin/cargo/commands/install.rs
Outdated
if url.contains('#') { | ||
return Err(anyhow::format_err!( | ||
"invalid git url to install from\n\n\ | ||
help: use `--rev <SHA>` to specify a commit" | ||
) | ||
.into()); | ||
} | ||
|
||
let url = url.into_url()?; |
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.
Should this check be done on the parsed URL, rather than on the string?
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.
Thanks, yeah. That makes a lot of sense.
src/bin/cargo/commands/install.rs
Outdated
if url.contains('#') { | ||
return Err(anyhow::format_err!( | ||
"invalid git url to install from\n\n\ | ||
help: use `--rev <SHA>` to specify a commit" | ||
) | ||
.into()); | ||
} | ||
|
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.
Is this definitively a bad URL or should this be a hint on the existing error?
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.
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.
Cargo supports more than Github. The question would be more about the git protocol and what is expected around it as we could be turning a success case into an error case.
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.
From what I'm seeing here, other git servers should be the same.
return error if the git url contains a # and hint user to use --rev
552440b
to
dcc8cef
Compare
Check if the git url contains a '#' which is likely a sign for the user's desire to specify a rev. Give hint to use
--rev
Fixes #15336