-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(yank): Support foo@version like cargo-add #10597
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ fn setup(name: &str, version: &str) { | |
} | ||
|
||
#[cargo_test] | ||
fn simple() { | ||
fn explicit_version() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
|
@@ -46,3 +46,116 @@ Caused by: | |
) | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn inline_version() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("yank [email protected] --token sekrit").run(); | ||
|
||
p.cargo("yank --undo [email protected] --token sekrit") | ||
.with_status(101) | ||
.with_stderr( | ||
" Updating `[..]` index | ||
Unyank [email protected] | ||
error: failed to undo a yank from the registry at file:///[..] | ||
|
||
Caused by: | ||
EOF while parsing a value at line 1 column 0", | ||
) | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn version_required() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("yank foo --token sekrit") | ||
.with_status(101) | ||
.with_stderr("error: `--version` is required") | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn inline_version_without_name() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("yank @0.0.1 --token sekrit") | ||
.with_status(101) | ||
.with_stderr("error: missing crate name for `@0.0.1`") | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn inline_and_explicit_version() { | ||
registry::init(); | ||
setup("foo", "0.0.1"); | ||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
description = "foo" | ||
"#, | ||
) | ||
.file("src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
p.cargo("yank [email protected] --version 0.0.1 --token sekrit") | ||
.with_status(101) | ||
.with_stderr("error: cannot specify both `@0.0.1` and `--version`") | ||
.run(); | ||
} |
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.
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.
Could we remove the
.map(|s| s.to_string())
for all these arguments and makeops::yank
takeOption<&str>
instead?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.
imo
String
is wider than justyank
, its most Op options (though sometimes we do see a&str
or a mix ofString
and&str
)String
is slightly more ergonomic though that is diminished by having a&Config
in theOptions
and no one will ever notice the performance difference in these (thinking back to the RustConf talk about "just clone and stop worrying about it).