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

Add version normalization #972

Merged
merged 5 commits into from
Feb 29, 2024
Merged

Add version normalization #972

merged 5 commits into from
Feb 29, 2024

Conversation

jrray
Copy link
Collaborator

@jrray jrray commented Feb 13, 2024

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

@jrray jrray added the enhancement New feature or request label Feb 13, 2024
@jrray jrray self-assigned this Feb 13, 2024
@jrray jrray force-pushed the jrray/issue/969 branch 2 times, most recently from 0ff84c5 to 8d6b85a Compare February 13, 2024 23:48
@jrray jrray requested a review from rydrman February 14, 2024 00:45
@jrray
Copy link
Collaborator Author

jrray commented Feb 16, 2024

@rydrman thanks for the approval, I'm waiting to merge this until some more tests have been implemented (#976).

@jrray jrray force-pushed the jrray/issue/969 branch 2 times, most recently from dacb319 to a8bf54e Compare February 21, 2024 00:33
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 jrray merged commit cc0b8cc into main Feb 29, 2024
5 checks passed
@jrray jrray deleted the jrray/issue/969 branch February 29, 2024 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement version normalization for spk packages
2 participants