Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move upgradeable check to using semVer/pre #1110

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

rgee0
Copy link
Contributor

@rgee0 rgee0 commented Aug 8, 2024

Description

The number of tag version edge cases requiring exception from being upgraded was increasing to the point where constantly adding to the exception list was no longer a viable approach.

This change alters how the upgradability of a tag is assessed by parsing the current and latest tags into SemVers and then assessing the pre field of the version to determine whether either of the tags are a special case. In order to achieve this it is necessary to move latest out to be a case all of itself as this would not be nicely handled by NewVersion().

Motivation and Context

  • I have raised an issue to propose this change, which has been given a label of design/approved by a maintainer (required)

How Has This Been Tested?

Unit only.

If updating or adding a new CLI to arkade get, run:

go build && ./hack/test-tool.sh TOOL_NAME

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Documentation

  • I have updated the list of tools in README.md if (required) with ./arkade get --format markdown
  • I have updated the list of apps in README.md if (required) with ./arkade install --help

Checklist:

  • [ x] My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [ x] I've read the CONTRIBUTION guide
  • [x ] I have signed-off my commits with git commit -s
  • I have tested this on arm, or have added code to prevent deployment

The number of tag version edge cases requiring exception from being upgraded
was increasing to the point where constantly adding to the exception list was
no longer a viable approach.

This change alters how the upgradability of a tag is assessed by parsing the
current and latest tags into SemVers and then assessing the `pre` field of the
version to determine whether either of the tags are a special case.  In order
to achieve this it is necessary to move `latest` out to be a case all of itself
as this would not be nicely handled by NewVersion().

Signed-off-by: Richard Gee <[email protected]>
currentSemVer, _ := semver.NewVersion(currentTag)
latestSemVer, _ := semver.NewVersion(latestTag)

return latestTag != currentTag && len(latestSemVer.Prerelease()) == 0 && len(currentSemVer.Prerelease()) == 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the case where the value is v0.15.1-rootless and we want to go up to v0.15.2-rootless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will not upgrade.

To achieve that we would need to check that the current/latest prereleases match.

Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexellis alexellis merged commit 2fb58a4 into alexellis:master Aug 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants