Skip to content

feat: print one project's version with version --current --project-name - #28

Merged
philasmar merged 1 commit into
devfrom
asmarp/version-current-project-name
Sep 16, 2026
Merged

philasmar merged 1 commit into
devfrom
asmarp/version-current-project-name

Conversation

@philasmar

Copy link
Copy Markdown
Owner

version --current can only produce a capturable value for a single-project repository. With several projects it prints them labeled:

Project1: 1.2.3
Project2: 4.5.6

which is readable but not assignable, so VERSION=$(autover version --current) silently becomes multi-line text. A pipeline publishing more than one artifact from one repository has no way to ask for the version it needs.

This adds --project-name to version, meaningful alongside --current:

VERSION=$(autover version --current --project-name "Project2")   # 4.5.6

Bare output regardless of how many projects are configured. The name matches exactly as change --project-name already does.

Why it came up

A container-image repository that builds two images from two Dockerfiles. Two projects with their own Path gives them independent versions, which is what you want — but then the publish step can't read either one. The alternatives were worse: parse the labeled display format in shell, or collapse both images onto one version they don't actually share.

Behaviour

  • Unknown name is an error, listing the configured names, rather than empty output. Left unvalidated, a typo sets VERSION="" and publishes an untagged or mis-tagged artifact — a silent failure in exactly the place it hurts.
  • Paths drift is an error. A project using Paths shares one version across its files by definition. If those files disagree, printing the first would quietly publish a version that doesn't match what's in the other file, so it says so instead.
  • VersionFromTag already prints a single repository-wide version; naming a project there is redundant but still validated, so a typo is caught rather than ignored.
  • Omitted, nothing changes.

Tests

Three added to VersionCommandTests, alongside the existing single-project --current test:

  • M — several projects without --project-name still print labeled. Asserts the contract the new option exists to work around, which had no coverage at all.
  • N — --project-name prints that project bare, with nothing about the other one.
  • O — unknown name exits UserError, names what is configured, no stack trace, empty stdout.

Full suite: 103 integration, 190 unit, 0 failures.

Note for anyone running these locally: dotnet test reports "Zero tests ran" for these projects — TUnit builds self-hosting test executables, so run test/AutoVer.IntegrationTests/bin/Debug/net10.0/AutoVer.IntegrationTests directly (optionally with --treenode-filter).

@philasmar
philasmar merged commit c8c6461 into dev Sep 16, 2026
2 of 3 checks passed
@philasmar
philasmar deleted the asmarp/version-current-project-name branch September 16, 2026 14:44
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