diff --git a/currentVersions.go b/currentVersions.go index 1c2c822..65e40ed 100644 --- a/currentVersions.go +++ b/currentVersions.go @@ -264,22 +264,26 @@ func splitVersion(version string) (a, b, c string) { } } +func splitInts(ver string) (int, int, int) { + major, minor, revision := splitVersion(ver) + a, _ := strconv.Atoi(major) + b, _ := strconv.Atoi(minor) + c, _ := strconv.Atoi(revision) + return a, b, c +} + // changes the target minor. v0.1.3 becomes v0.2.0 func (repo *Repo) IncrementTargetMinor() { lasttag := repo.GetLastTag() - var major, minor, revision string - major, minor, revision = splitVersion(lasttag) + // var major, minor, revision string + major, minor, revision := splitInts(lasttag) - olda, _ := strconv.Atoi(major) - oldb, _ := strconv.Atoi(minor) - oldc, _ := strconv.Atoi(revision) + minor += 1 + revision = 0 - oldb += 1 - oldc = 0 - - newa := strconv.Itoa(olda) - newb := strconv.Itoa(oldb) - newc := strconv.Itoa(oldc) + newa := strconv.Itoa(major) + newb := strconv.Itoa(minor) + newc := strconv.Itoa(revision) repo.SetTargetVersion("v" + newa + "." + newb + "." + newc) } @@ -290,33 +294,28 @@ func (repo *Repo) IncrementTargetRevision() bool { repo.incrementRevision(repo.GetLastTag()) if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) { - log.Info("master version() is higher than target version", repo.GetMasterVersion(), repo.GetTargetVersion()) + log.Printf("master version() %s is higher than target version %s\n", repo.GetMasterVersion(), repo.GetTargetVersion()) repo.incrementRevision(repo.GetMasterVersion()) } if !isNewerVersion(repo.GetLastTag(), repo.GetTargetVersion()) { - log.Info("last tag versn() is higher than target version", repo.GetLastTag(), repo.GetTargetVersion()) + log.Printf("last tag versn() %s is higher than target version %s\n", repo.GetLastTag(), repo.GetTargetVersion()) return false } if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) { - log.Info("master version() is higher than target version", repo.GetMasterVersion(), repo.GetTargetVersion()) + log.Printf("master version() %s is higher than target version %s\n", repo.GetMasterVersion(), repo.GetTargetVersion()) return false } return true } func (repo *Repo) incrementRevision(lasttag string) { - var major, minor, revision string - major, minor, revision = splitVersion(lasttag) + major, minor, revision := splitInts(lasttag) - olda, _ := strconv.Atoi(major) - oldb, _ := strconv.Atoi(minor) - oldc, _ := strconv.Atoi(revision) + revision += 1 - oldc += 1 - - newa := strconv.Itoa(olda) - newb := strconv.Itoa(oldb) - newc := strconv.Itoa(oldc) + newa := strconv.Itoa(major) + newb := strconv.Itoa(minor) + newc := strconv.Itoa(revision) repo.SetTargetVersion("v" + newa + "." + newb + "." + newc) } @@ -330,8 +329,8 @@ func (repo *Repo) incrementRevision(lasttag string) { // B = minor = 1 // C = revision = 4 func isNewerVersion(oldver, newver string) bool { - olda, oldb, oldc := splitVersion(oldver) - newa, newb, newc := splitVersion(newver) + olda, oldb, oldc := splitInts(oldver) + newa, newb, newc := splitInts(newver) if newa < olda { return false