Skip to content
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

switch semver package to Masterminds/semver from blang/semver #11

Merged
merged 1 commit into from
Dec 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions gobump.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"go/printer"
"go/token"

"github.com/blang/semver"
"github.com/Masterminds/semver"
)

// Gobump is main application struct
Expand Down Expand Up @@ -272,32 +272,35 @@ func (conf Config) ProcessNode(fset *token.FileSet, node ast.Node) (versions map
// bumpedVersion returns new bumped-up version according to given spec.
func (conf Config) bumpedVersion(version string) (string, error) {
if conf.Exact != "" {
exact, err := semver.New(conf.Exact)
exact, err := semver.StrictNewVersion(conf.Exact)
if err != nil {
return "", err
}
if v, err := semver.Parse(version); err == nil {
if !exact.GT(v) {
if v, err := semver.StrictNewVersion(version); err == nil {
if !exact.GreaterThan(v) {
return "", fmt.Errorf("version %s is not greater than the current version", exact)
}
}
return exact.String(), nil
}

v, err := semver.Parse(version)
v, err := semver.StrictNewVersion(version)
if err != nil {
return "", err
}

if conf.MajorDelta > 0 {
v.Major = v.Major + conf.MajorDelta
v.Minor = 0
v.Patch = 0
for i := uint64(0); i < conf.MajorDelta; i++ {
*v = v.IncMajor()
}
} else if conf.MinorDelta > 0 {
v.Minor = v.Minor + conf.MinorDelta
v.Patch = 0
for i := uint64(0); i < conf.MinorDelta; i++ {
*v = v.IncMinor()
}
} else if conf.PatchDelta > 0 {
v.Patch = v.Patch + conf.PatchDelta
for i := uint64(0); i < conf.PatchDelta; i++ {
*v = v.IncPatch()
}
}

return v.String(), nil
Expand Down