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

Commits on Feb 26, 2024

  1. Add version normalization

    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>
    jrray committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    37cc2f1 View commit details
    Browse the repository at this point in the history
  2. VersionParts::normalize no longer returns an empty list

    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>
    jrray committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    2cc5547 View commit details
    Browse the repository at this point in the history
  3. Create strategy trait for tag_path

    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>
    jrray committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    6b0c184 View commit details
    Browse the repository at this point in the history
  4. Add legacy-spk-version-tags feature

    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>
    jrray committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    1a0942b View commit details
    Browse the repository at this point in the history
  5. Change normalization scheme to have a minimum number of parts

    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 committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    dac0fe5 View commit details
    Browse the repository at this point in the history