Skip to content

Commit

Permalink
refactoring: extract variables
Browse files Browse the repository at this point in the history
  • Loading branch information
René Galle committed Apr 2, 2020
1 parent 43b07f2 commit 733da33
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ func Next(current string, patternNext string) (string, error) {
nextMinor := versionNext.Minor()
nextPatch := versionNext.Patch()

currentMajor := currentVersion.Major()
currentMinor := currentVersion.Minor()
currentPatch := currentVersion.Patch()

switch positionX {
case positionMajor:
if currentVersion.Minor() == versionNext.Minor() && currentVersion.Patch() == versionNext.Patch() {
nextMajor = currentVersion.Major() + 1
if currentMinor == nextMinor && currentPatch == nextPatch {
nextMajor = currentMajor + 1
}
case positionMinor:
if currentVersion.Major() == versionNext.Major() && currentVersion.Patch() == versionNext.Patch() {
nextMinor = currentVersion.Minor() + 1
if currentMajor == nextMajor && currentPatch == nextPatch {
nextMinor = currentMinor + 1
}
case positionPatch:
if currentVersion.Major() == versionNext.Major() && currentVersion.Minor() == versionNext.Minor() {
nextPatch = currentVersion.Patch() + 1
if currentMajor == nextMajor && currentMinor == nextMinor {
nextPatch = currentPatch + 1
}
}
var result string
Expand Down

0 comments on commit 733da33

Please sign in to comment.