Skip to content

Commit

Permalink
tools/bumper: Fix #sha characters in vtag
Browse files Browse the repository at this point in the history
The bumper currently assumes that virtual tags consists of eight sha
characters after the "g" (for example: v0.39.0-32-g12345678.
This is not the default configuration (which is seven).
Fixing unit tests to use character aligned to the default.

Also, as this bumper of sha characters is configurable, changing the
regex in isVtagFormat to accept any number of character (bigger than
one) as a valid vtag format.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Sep 10, 2024
1 parent 520da34 commit 60687e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tools/bumper/cnao_repo_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ func canonicalizeVersion(version string) (*semver.Version, error) {
return semver.NewVersion(version)
}

// check vtag format (example: 0.39.0-32-g1fcbe815)
// check vtag format (example: 0.39.0-32-g1fbe815)
func isVtagFormat(tagVersion string) bool {
var vtagSyntax = regexp.MustCompile(`^v[0-9]\.[0-9]+\.*[0-9]*-[0-9]+-g[0-9,a-f]{8}`)
var vtagSyntax = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g[a-zA-Z0-9]+$`)
return vtagSyntax.MatchString(tagVersion)
}

Expand Down
10 changes: 5 additions & 5 deletions tools/bumper/cnao_repo_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
expectedResult: false,
}),
Entry("When using vtag version format, Should recognize as vtag format", isVtagFormatParams{
version: "v0.39.0-32-g1fcbe815",
version: "v0.39.0-32-g1fbe815",
expectedResult: true,
}),
)
Expand Down Expand Up @@ -230,7 +230,7 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
}),
Entry("Should bump when latestReleaseVersion is in vtag-format", isComponentBumpNeededParams{
currentReleaseVersion: "v0.20.9",
latestReleaseVersion: "v0.20.9-1-g4cd31235",
latestReleaseVersion: "v0.20.9-1-g4cd3135",
updatePolicy: "latest",
prTitle: dummyPRTitle,
isBumpExpected: true,
Expand Down Expand Up @@ -277,16 +277,16 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
isValid: false,
}),
Entry("Should bump when currentReleaseVersion is in vtag-format", isComponentBumpNeededParams{
currentReleaseVersion: "v0.44.1-4-g4cd33665",
currentReleaseVersion: "v0.44.1-4-g4d33665",
latestReleaseVersion: "v0.43.1",
updatePolicy: "latest",
prTitle: dummyPRTitle,
isBumpExpected: true,
isValid: true,
}),
Entry("Should not bump when currentReleaseVersion is in vtag-format and equals latestReleaseVersion", isComponentBumpNeededParams{
currentReleaseVersion: "v0.36.2-5-g4cd4566",
latestReleaseVersion: "v0.36.2-5-g4cd4566",
currentReleaseVersion: "v0.36.2-5-g4d4566",
latestReleaseVersion: "v0.36.2-5-g4d4566",
updatePolicy: "latest",
prTitle: dummyPRTitle,
isBumpExpected: false,
Expand Down

0 comments on commit 60687e1

Please sign in to comment.