Skip to content

Sort -alpha, -beta and -rc tags below their release - #158

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/153-versionsort-suffixes
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/153-versionsort-suffixes

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #153

Problem

GitService.GetTagsAsync ran git config versionsort.suffix "<s>" once for each of -alpha, -beta, -rc and -pre. Each call replaced the previous value, so only -pre was kept. That caused three problems:

  • v1.2.3-rc.1 sorted above v1.2.3, so VersionCalculator and ChangelogGenerator, which both read tags[0], took the release candidate as the latest release.
  • Every call rewrote .git/config, including on developer checkouts.
  • ReleaseService did not treat -rc as a prerelease, so an RC was published as a full GitHub release.

Change

  • GetTagsAsync now runs a single git -c versionsort.suffix=-alpha -c versionsort.suffix=-beta -c versionsort.suffix=-rc -c versionsort.suffix=-pre tag --list --sort=-v:refname. Repeated -c options accumulate for that one invocation, and nothing is written to config. The argument string is GitService.ListTagsArguments, and the pipeline test's fake runner now matches on it.
  • ReleaseService also marks -rc versions as prereleases.

Tests

  • GetTagsAsync_RealRepository_SortsPrereleaseBelowItsRelease (rc/alpha/beta/pre) runs against a real temporary git repo with tags v1.2.2, v1.2.3-<label>.1 and v1.2.3. It asserts the order v1.2.3, then the prerelease, then v1.2.2, and that no versionsort.suffix ends up in the repo config.
  • GetTagsAsync_PassesEveryVersionSortSuffixWithoutWritingConfig replaces the old test, which asserted the four git config calls.
  • ExecuteReleaseAsync_DetectsPrerelease_ReleaseCandidate.

With the fix reverted, the rc/alpha/beta sort cases and the RC-prerelease test fail. With the fix, the full suite passes (748/748).

🤖 Generated with Claude Code

https://claude.ai/code/session_011EmfGBmvKNA36fj7HFaVgb


Generated by Claude Code

GetTagsAsync set versionsort.suffix with four separate git config calls,
each of which overwrote the last, so only -pre survived. A v1.2.3-rc.1
tag then sorted above v1.2.3, and the version calculator and changelog
took the release candidate as the latest release. Every call also
rewrote the repository's .git/config.

Pass the suffixes as repeated -c options on the tag listing instead.
They accumulate for that one invocation and nothing is written to
config. Also mark -rc versions as GitHub prereleases.

Fixes #153

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011EmfGBmvKNA36fj7HFaVgb
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 83aafea into main Sep 28, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/153-versionsort-suffixes branch September 28, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant