[repo-assist] Fix inconsistent ~> LOCKEDVERSION twiddle range for short version strings - #4416
Merged
dsyme merged 1 commit intoSep 1, 2026
Conversation
…ings (#3727) The bare LOCKEDVERSION/CURRENTVERSION placeholder substituted the raw, un-normalized locked version text (e.g. "0.68") instead of a normalized Major.Minor.Patch form. Since the ~> twiddle operator infers which segment to bump from the number of numeric fragments in the version text, a 2-segment locked version (e.g. "0.68") produced a different (and unintended) upper bound than a 3-segment version (e.g. "0.68.1"), even though both represent the same logical minor version. Normalize the substituted version to at least 3 segments (Major.Minor.Patch), preserving any pre-release/build suffix, so ~> LOCKEDVERSION behaves consistently regardless of how many segments appear in paket.lock. Added a regression test covering 2-segment, 3-segment (explicit patch=0), and 3-segment (non-zero patch) locked versions with ~> LOCKEDVERSION, verifying they all now produce the same kind of twiddle range. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or 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
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.
🤖 This is an automated response from Repo Assist, an AI assistant.
Closes #3727
Root cause
In
paket.template, the bareLOCKEDVERSION/CURRENTVERSIONplaceholder (with no:Major/:Minor/:Patch/:Buildspec) substituted the raw, un-normalized locked version text (e.g."0.68") verbatim into the dependency line, instead of a normalizedMajor.Minor.Patchform.That raw text then feeds into the
~>(twiddle) operator parser, which infers which segment to bump based on how many numeric fragments are present in the text (DependenciesFileParser.twiddle). As a result:0.68(2 segments) →~> LOCKEDVERSIONproduced[0.68, 1.0.0)0.68.1(3 segments) →~> LOCKEDVERSIONproduced[0.68.1, 0.69.0)Both represent "the same" minor version conceptually, but yielded very different (and for the 2-segment case, unintended) upper bounds — exactly the inconsistency reported in #3727.
Fix
In
TemplateFile.fs, when no explicit segment spec is given, the substituted version text is now padded to at least 3 segments (Major.Minor.Patch), preserving any pre-release/build suffix from the original source text. This makes~> LOCKEDVERSION(and similar unspecced placeholders) behave consistently regardless of how many segments the locked version happens to have inpaket.lock.This only affects the no-spec case (
segmentCount = 0); explicit:Major/:Minor/:Patch/:Buildspecs are unchanged.Trade-offs
paket.templaterelying on the old (inconsistent) raw substitution for short (1–2 segment) locked versions combined with~>. However, the old behavior was a bug with no clear intentional use, so this is considered a bugfix rather than a breaking change.Specific) substitution behavior for bareLOCKEDVERSION(without~>) was already normalizing 2-segment versions to 3 segments in existing tests (e.g."1.2"→"1.2.0"), so this fix is consistent with, and does not change, that existing behavior.Test Status
dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~TemplateFile"(net9.0): 104/104 passed (including 3 new regression test cases added for this fix).dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~Version|FullyQualifiedName~Template|FullyQualifiedName~Twiddle"(net9.0): 294/294 passed.net461test target could not run in this sandbox (missing Mono host) — this is an environment limitation, not a code issue; net9.0 results are the reliable signal here.AI Disclosure
This PR was authored autonomously by Repo Assist, an automated AI assistant for this repository. Please review carefully before merging.
Add this agentic workflow to your repo
To install this agentic workflow, run