super dumb logic error here
This commit is contained in:
parent
4d093bc1e3
commit
676cb338a4
|
@ -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
|
// changes the target minor. v0.1.3 becomes v0.2.0
|
||||||
func (repo *Repo) IncrementTargetMinor() {
|
func (repo *Repo) IncrementTargetMinor() {
|
||||||
lasttag := repo.GetLastTag()
|
lasttag := repo.GetLastTag()
|
||||||
var major, minor, revision string
|
// var major, minor, revision string
|
||||||
major, minor, revision = splitVersion(lasttag)
|
major, minor, revision := splitInts(lasttag)
|
||||||
|
|
||||||
olda, _ := strconv.Atoi(major)
|
minor += 1
|
||||||
oldb, _ := strconv.Atoi(minor)
|
revision = 0
|
||||||
oldc, _ := strconv.Atoi(revision)
|
|
||||||
|
|
||||||
oldb += 1
|
newa := strconv.Itoa(major)
|
||||||
oldc = 0
|
newb := strconv.Itoa(minor)
|
||||||
|
newc := strconv.Itoa(revision)
|
||||||
newa := strconv.Itoa(olda)
|
|
||||||
newb := strconv.Itoa(oldb)
|
|
||||||
newc := strconv.Itoa(oldc)
|
|
||||||
|
|
||||||
repo.SetTargetVersion("v" + newa + "." + newb + "." + newc)
|
repo.SetTargetVersion("v" + newa + "." + newb + "." + newc)
|
||||||
}
|
}
|
||||||
|
@ -290,33 +294,28 @@ func (repo *Repo) IncrementTargetRevision() bool {
|
||||||
repo.incrementRevision(repo.GetLastTag())
|
repo.incrementRevision(repo.GetLastTag())
|
||||||
|
|
||||||
if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) {
|
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())
|
repo.incrementRevision(repo.GetMasterVersion())
|
||||||
}
|
}
|
||||||
if !isNewerVersion(repo.GetLastTag(), repo.GetTargetVersion()) {
|
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
|
return false
|
||||||
}
|
}
|
||||||
if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) {
|
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 false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) incrementRevision(lasttag string) {
|
func (repo *Repo) incrementRevision(lasttag string) {
|
||||||
var major, minor, revision string
|
major, minor, revision := splitInts(lasttag)
|
||||||
major, minor, revision = splitVersion(lasttag)
|
|
||||||
|
|
||||||
olda, _ := strconv.Atoi(major)
|
revision += 1
|
||||||
oldb, _ := strconv.Atoi(minor)
|
|
||||||
oldc, _ := strconv.Atoi(revision)
|
|
||||||
|
|
||||||
oldc += 1
|
newa := strconv.Itoa(major)
|
||||||
|
newb := strconv.Itoa(minor)
|
||||||
newa := strconv.Itoa(olda)
|
newc := strconv.Itoa(revision)
|
||||||
newb := strconv.Itoa(oldb)
|
|
||||||
newc := strconv.Itoa(oldc)
|
|
||||||
|
|
||||||
repo.SetTargetVersion("v" + newa + "." + newb + "." + newc)
|
repo.SetTargetVersion("v" + newa + "." + newb + "." + newc)
|
||||||
}
|
}
|
||||||
|
@ -330,8 +329,8 @@ func (repo *Repo) incrementRevision(lasttag string) {
|
||||||
// B = minor = 1
|
// B = minor = 1
|
||||||
// C = revision = 4
|
// C = revision = 4
|
||||||
func isNewerVersion(oldver, newver string) bool {
|
func isNewerVersion(oldver, newver string) bool {
|
||||||
olda, oldb, oldc := splitVersion(oldver)
|
olda, oldb, oldc := splitInts(oldver)
|
||||||
newa, newb, newc := splitVersion(newver)
|
newa, newb, newc := splitInts(newver)
|
||||||
|
|
||||||
if newa < olda {
|
if newa < olda {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue