-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add version normalization #972
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jrray
force-pushed
the
jrray/issue/969
branch
2 times, most recently
from
February 13, 2024 23:48
0ff84c5
to
8d6b85a
Compare
rydrman
approved these changes
Feb 16, 2024
jrray
force-pushed
the
jrray/issue/969
branch
2 times, most recently
from
February 21, 2024 00:33
dacb319
to
a8bf54e
Compare
With these changes there are three ways to parse a version number and render it back into a string: 1. verbatim: "1.0" remains "1.0" 2. normalized for display: "1.0" becomes "1.0.0" 3. normalized for storage: "1.0" becomes "1" The default is (2), e.g., when using Version::to_string. The verbatim case is used for preserving how versions were originally written in recipes, for purposes of formatting error messages that contain the original input, and for serializing the recipe and preserving the original value. The storage case is used for creating the spfs tag path, so that it doesn't matter how many trailing zeros a version has in a recipe. The normalized case is used in contexts where the verbatim case doesn't apply, like in the output of `spk ls`, to make the output look more uniform. Closes #969 Signed-off-by: J Robert Ray <jrray@jrray.org>
In the degenerate case of all zeros, the workaround of checking different lengths of trailing zeros would check the '0' case twice unintentionally. Signed-off-by: J Robert Ray <jrray@jrray.org>
Eliminate code duplication by having tag_path be generic over the strategy to use to generate the path. This also forces callers of tag_path to consider what kind of path is needed. Signed-off-by: J Robert Ray <jrray@jrray.org>
Put handling of non-conforming content in existing spfs repos behind a feature gate. New users will not need to enable this and will not incur the overhead of checking multiple possible ways a spk package version might be appear in spfs storage. Signed-off-by: J Robert Ray <jrray@jrray.org>
Instead of normalizing "1.0.0" to "1", maintain a minimum size of three parts in the interest of making the tag names more consistent and being less of a disruptive change from the previous behavior. An existing package using version "1.0.0" would not start being saved to a different directory, avoiding potential backwards compatibility issues. Rename `Version::normalize` to `Version::strip_trailing_zeros` to avoid confusion around what that method is expected to do and the fact that it now returns something that doesn't match what a "normalized" version would be now. Signed-off-by: J Robert Ray <jrray@jrray.org>
jrray
force-pushed
the
jrray/issue/969
branch
from
February 26, 2024 22:27
a8bf54e
to
dac0fe5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With these changes there are three ways to parse a version number and
render it back into a string:
The default is (2), e.g., when using Version::to_string.
The verbatim case is used for preserving how versions were originally
written in recipes, for purposes of formatting error messages that
contain the original input, and for serializing the recipe and
preserving the original value.
The storage case is used for creating the spfs tag path, so that it
doesn't matter how many trailing zeros a version has in a recipe.
The normalized case is used in contexts where the verbatim case doesn't
apply, like in the output of
spk ls
, to make the output look moreuniform.
Closes #969