File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -523,8 +523,16 @@ impl SourceId {
523
523
version : semver:: Version ,
524
524
precise : & str ,
525
525
) -> CargoResult < SourceId > {
526
- let precise = semver:: Version :: parse ( precise)
527
- . with_context ( || format ! ( "invalid version format for precise version `{precise}`" ) ) ?;
526
+ let precise = semver:: Version :: parse ( precise) . with_context ( || {
527
+ if let Some ( stripped) = precise. strip_prefix ( "v" ) {
528
+ return format ! (
529
+ "the version provided, `{precise}` is not a \
530
+ valid SemVer version\n \n \
531
+ help: try changing the version to `{stripped}`",
532
+ ) ;
533
+ }
534
+ format ! ( "invalid version format for precise version `{precise}`" )
535
+ } ) ?;
528
536
529
537
Ok ( SourceId :: wrap ( SourceIdInner {
530
538
precise : Some ( Precise :: Updated {
Original file line number Diff line number Diff line change @@ -2737,7 +2737,9 @@ fn prefixed_v_in_version() {
2737
2737
p. cargo ( "update bar --precise v1.0.1" )
2738
2738
. with_status ( 101 )
2739
2739
. with_stderr_data ( str![ [ r#"
2740
- [ERROR] invalid version format for precise version `v1.0.1`
2740
+ [ERROR] the version provided, `v1.0.1` is not a valid SemVer version
2741
+
2742
+ [HELP] try changing the version to `1.0.1`
2741
2743
2742
2744
Caused by:
2743
2745
unexpected character 'v' while parsing major version number
You can’t perform that action at this time.
0 commit comments