Skip to content

fix(author): enforce semver matching and numeric template ordering - #2164

Open
Acuspeedster wants to merge 1 commit into
oscal-compass:developfrom
Acuspeedster:fix/template-versioning-semver-ordering
Open

fix(author): enforce semver matching and numeric template ordering#2164
Acuspeedster wants to merge 1 commit into
oscal-compass:developfrom
Acuspeedster:fix/template-versioning-semver-ordering

Conversation

@Acuspeedster

@Acuspeedster Acuspeedster commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Types of changes

  • Hot fix (emergency fix and release)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation (change which affects the documentation site)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Release (develop -> main)

Quality assurance (all should be covered).

  • My code follows the code style of this project.
  • Documentation for my change is up to date?
  • My PR meets testing requirements.
  • All new and existing tests passed.
  • All commits are signed-off.

Summary

Fix template version parsing and ordering so template directories are identified strictly by semantic version and latest version selection is numeric (not lexicographic).

Changes made:

  • TEMPLATE_VERSION_REGEX is now strict semver (^X.Y.Z$) instead of a loose pattern.
  • TemplateVersioning.update_template_folder_structure() now uses strict full-match checks for version folders.
  • TemplateVersioning.get_all_versions_for_task() now includes only strict semver directory names.
  • TemplateVersioning.get_latest_version_for_task() now sorts versions numerically by (major, minor, patch).
  • TemplateVersioning.is_valid_version() now uses the shared strict regex constant.
  • Added regression tests for:
    • numeric ordering (10.0.0 over 2.0.0)
    • strict semver-only directory filtering.

Files updated:

  • trestle/common/const.py
  • trestle/core/commands/author/versioning/template_versioning.py
  • tests/trestle/core/commands/author/versioning/template_versioning_test.py

Validation run:

  • pytest tests/trestle/core/commands/author/versioning/template_versioning_test.py -q --basetemp .pytest_tmp
  • Result: 9 passed

Key links:

Before you merge

  • Ensure it is a 'squash commit' if not a release.
  • Ensure CI is currently passing
  • Check sonar. If you are working for a fork a maintainer will reach out, if required.

Signed-off-by: Acuspeedster <arnavrajsingh@gmail.com>
@Acuspeedster
Acuspeedster requested a review from a team as a code owner March 17, 2026 19:26
@degenaro
degenaro force-pushed the develop branch 2 times, most recently from 64cc98c to 4fa5f11 Compare August 7, 2026 11:15
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.

1 participant