Skip to content

Commit

Permalink
fix: semvar compare logic fixed (#853) (#854)
Browse files Browse the repository at this point in the history
(cherry picked from commit cb899e9)

Co-authored-by: Tanmoy Sarkar <[email protected]>
  • Loading branch information
mergify[bot] and tanmoysrt authored Jun 23, 2024
1 parent 158e3b7 commit 6bdc749
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion swiftwave_service/graphql/stack.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions swiftwave_service/stack_parser/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func ParseStackYaml(yamlStr string, currentSwiftwaveVersion string) (Stack, erro
return Stack{}, err
}
// convert the version to integer
if !isCurrentVersionLargerThanMinimum(stack.MinimumSwiftwaveVersion, currentSwiftwaveVersion) {
if !isCurrentVersionSameOrLargerThanMinimum(stack.MinimumSwiftwaveVersion, currentSwiftwaveVersion) {
return Stack{}, fmt.Errorf(`required Swiftwave %s. Current Version %s. Please upgrade to latest`, stack.MinimumSwiftwaveVersion, currentSwiftwaveVersion)
}
// Pre-fill default values
Expand Down Expand Up @@ -391,13 +391,17 @@ func fillDefaultDockerProxyPermissionIfNotPresent(val DockerProxyPermissionType)
return DockerProxyNoPermission
}

func isCurrentVersionLargerThanMinimum(minimumVersion, currentVersion string) bool {
func isCurrentVersionSameOrLargerThanMinimum(minimumVersion, currentVersion string) bool {
if strings.Compare(currentVersion, "develop") == 0 || strings.Compare(currentVersion, "") == 0 {
return true
}
minimumVersion = cleanUpVersion(minimumVersion)
currentVersion = cleanUpVersion(currentVersion)

if strings.Compare(minimumVersion, currentVersion) == 0 {
return true
}

minParts := strings.Split(minimumVersion, ".")
currentParts := strings.Split(currentVersion, ".")

Expand Down

0 comments on commit 6bdc749

Please sign in to comment.