diff --git a/internal/cli/bumpver.go b/internal/cli/bumpver.go index 6d6f1992..400aadcd 100644 --- a/internal/cli/bumpver.go +++ b/internal/cli/bumpver.go @@ -1,6 +1,9 @@ package cli import ( + "errors" + "fmt" + "github.com/Masterminds/semver/v3" "github.com/futurice/jalapeno/internal/cli/option" "github.com/futurice/jalapeno/pkg/recipe" @@ -92,6 +95,9 @@ func runBumpVer(cmd *cobra.Command, opts bumpVerOpts) error { } else { optVer, err := semver.NewVersion(opts.RecipeVersion) if err != nil { + if errors.Is(err, semver.ErrInvalidSemVer) { + return fmt.Errorf("provided version is not valid semver: %s", opts.RecipeVersion) + } return err } diff --git a/test/features/bumpver.feature b/test/features/bumpver.feature index e59d1622..6f20ace0 100644 --- a/test/features/bumpver.feature +++ b/test/features/bumpver.feature @@ -2,17 +2,19 @@ Feature: Bump recipe version and write changelog Scenario: Directly bump version Given a recipe "foo" - When I bump recipe "foo" version to "v0.0.2" with message "Test" + When I bump recipe "foo" version to "v0.0.2" with message "Test" Then recipe "foo" has version "v0.0.2" + And CLI produced an output "bumped version: v0.0.1 => v0.0.2" And recipe "foo" has changelog message "Test" Scenario: Command inits changelog Given a recipe "foo" - When I bump recipe "foo" version to "v0.0.2" with message "Test" + When I bump recipe "foo" version to "v0.0.2" with message "Test" Then recipe "foo" contains changelog with 2 entries + And CLI produced an output "bumped version: v0.0.1 => v0.0.2" And first entry in recipe "foo" changelog has message "Init version" Scenario: Invalid semantic version Given a recipe "foo" - When I bump recipe "foo" version to "bar" with message "Test" - Then CLI produced an error "Error: Invalid Semantic Version" + When I bump recipe "foo" version to "no-valid-semver" with message "Test" + Then CLI produced an error "Error: provided version is not valid semver"