Skip to content

Commit

Permalink
mageutils:bugfix - major rc or beta was not working
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Martins <nathan.martins@zup.com.br>
  • Loading branch information
nathanmartinszup committed Nov 22, 2021
1 parent d01b7d2 commit ec2865e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
8 changes: 2 additions & 6 deletions pkg/utils/mageutils/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,11 @@ func CheckoutReleaseBranch(tag string) error {
return nil
}

// GitPushAll executes "git", "push", "--all" and "git", "push", "--tags"
// GitPushAll executes "git", "push", "--all"
func GitPushAll() error {
mg.Deps(isGitExistent)

if err := sh.RunV("git", "push", "--all"); err != nil {
return err
}

return sh.RunV("git", "push", "--tags")
return sh.RunV("git", "push", "--all")
}

// GitConfig configures global email and user for git
Expand Down
14 changes: 12 additions & 2 deletions pkg/utils/mageutils/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,25 @@ func (u *upVersions) upVersionNextBetaAndRc() {

// upVersionBeta increase the actual beta number by 1 and set next beta version
func (u *upVersions) upVersionBeta() {
major, minor, patch, beta := u.getSplittedVersionBetaOrRC(u.actualBetaVersion)
if u.releaseType == majorType && u.isOlderThanActualRelease(u.actualBetaVersion) {
u.nextBetaVersion = fmt.Sprintf("%s-beta.0", u.nextReleaseVersion)

return
}

major, minor, patch, beta := u.getSplittedVersionBetaOrRC(u.actualBetaVersion)
u.nextBetaVersion = fmt.Sprintf("v%s.%s.%s-beta.%s", major, minor, patch, u.upVersion(beta))
}

// upVersionRC increase the actual rc number by 1 and set next rc version
func (u *upVersions) upVersionRC() {
major, minor, patch, rc := u.getSplittedVersionBetaOrRC(u.actualRCVersion)
if u.releaseType == majorType && u.isOlderThanActualRelease(u.actualRCVersion) {
u.nextRCVersion = fmt.Sprintf("%s-rc.0", u.nextReleaseVersion)

return
}

major, minor, patch, rc := u.getSplittedVersionBetaOrRC(u.actualRCVersion)
u.nextRCVersion = fmt.Sprintf("v%s.%s.%s-rc.%s", major, minor, patch, u.upVersion(rc))
}

Expand Down
12 changes: 11 additions & 1 deletion pkg/utils/mageutils/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,23 @@ func TestVersion(t *testing.T) {
{
releaseType: "patch",
repositoryRelease: newMockRelease("v7.8.1"),
repositoryTags: newMockTags([]string{"v7.8.2-rc.2", "vv7.8.2-rc.1", "vv7.8.2-beta.3", "vv7.8.2-beta.2", "vv7.8.2-beta.1", "v7.8.1", "v7.8.0", "v7.8.0-rc.1", "v7.8.0-beta.1"}),
repositoryTags: newMockTags([]string{"v7.8.2-rc.2", "vv7.8.2-rc.1", "v7.8.2-beta.3", "v7.8.2-beta.2", "v7.8.2-beta.1", "v7.8.1", "v7.8.0", "v7.8.0-rc.1", "v7.8.0-beta.1"}),
expectedNextReleaseVersion: "v7.8.2",
expectedNextReleaseVersionStripped: "7.8.2",
expectedNextReleaseBranchName: "release/v7.8",
expectedNextBetaVersion: "v7.8.2-beta.4",
expectedNextRCVersion: "v7.8.2-rc.3",
},
{
releaseType: "minor",
repositoryRelease: newMockRelease("v2.3.9"),
repositoryTags: newMockTags([]string{"v2.4.0-beta.1", "v2.3.9"}),
expectedNextReleaseVersion: "v2.4.0",
expectedNextReleaseVersionStripped: "2.4.0",
expectedNextReleaseBranchName: "release/v2.4",
expectedNextBetaVersion: "v2.4.0-beta.2",
expectedNextRCVersion: "v2.4.0-rc.1",
},
}

for index, testCase := range testCases {
Expand Down

0 comments on commit ec2865e

Please sign in to comment.