File tree 2 files changed +21
-8
lines changed
2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: command_prelude:: * ;
2
2
3
+ use anyhow:: Context ;
3
4
use cargo:: ops;
4
5
use cargo_credential:: Secret ;
5
6
@@ -60,5 +61,19 @@ fn resolve_crate<'k>(
60
61
krate = Some ( k) ;
61
62
version = Some ( v) ;
62
63
}
64
+
65
+ if let Some ( version) = version {
66
+ semver:: Version :: parse ( version) . with_context ( || {
67
+ if let Some ( stripped) = version. strip_prefix ( "v" ) {
68
+ return format ! (
69
+ "the version provided, `{version}` is not a \
70
+ valid SemVer version\n \n \
71
+ help: try changing the version to `{stripped}`",
72
+ ) ;
73
+ }
74
+ format ! ( "invalid version `{version}`" )
75
+ } ) ?;
76
+ }
77
+
63
78
Ok ( ( krate, version) )
64
79
}
Original file line number Diff line number Diff line change @@ -237,12 +237,10 @@ fn bad_version() {
237
237
. replace_crates_io ( registry. index_url ( ) )
238
238
. with_status ( 101 )
239
239
. with_stderr_data ( str![ [ r#"
240
- [UPDATING] crates.io index
241
- [YANK] foo@bar
242
- [ERROR] failed to yank from the registry at [ROOTURL]/api
240
+ [ERROR] invalid version `bar`
243
241
244
242
Caused by:
245
- [37] Couldn't read a file:// file (Couldn't open file [ROOT]/api/api/v1/crates/foo/bar/yank)
243
+ unexpected character 'b' while parsing major version number
246
244
247
245
"# ] ] )
248
246
. run ( ) ;
@@ -272,12 +270,12 @@ fn prefixed_v_in_version() {
272
270
. replace_crates_io ( registry. index_url ( ) )
273
271
. with_status ( 101 )
274
272
. with_stderr_data ( str![ [ r#"
275
- [UPDATING] crates.io index
276
-
277
- [ERROR] failed to yank from the registry at [ROOTURL]/api
273
+ [ERROR] the version provided, `v0.0.1` is not a valid SemVer version
274
+
275
+ [HELP] try changing the version to `0.0.1`
278
276
279
277
Caused by:
280
- [37] Couldn't read a file:// file (Couldn't open file [ROOT]/api/api/v1/crates/bar/v0.0.1/yank)
278
+ unexpected character 'v' while parsing major version number
281
279
282
280
"# ] ] )
283
281
. run ( ) ;
You can’t perform that action at this time.
0 commit comments