Skip to content

Stamp commit SHA / build date / dirty flag into --version (#1550) - #2193

Merged
Widthdom merged 2 commits into
mainfrom
fix-issue1550
May 16, 2026
Merged

Stamp commit SHA / build date / dirty flag into --version (#1550)#2193
Widthdom merged 2 commits into
mainfrom
fix-issue1550

Conversation

@Widthdom

@Widthdom Widthdom commented May 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • cdidx --version now stamps commit SHA, build date, and clean/dirty flag so dev builds are distinguishable from tagged releases in bug reports. Human output: cdidx v<ver> (commit <sha>, built <yyyy-mm-dd>, <clean|dirty>) on one line. New cdidx --version --json emits {name, version, commit, build_date, dirty} for support tooling.
  • Metadata is captured at build time by a new StampCdidxBuildMetadata MSBuild target that shells out to git rev-parse --short=7 HEAD and git diff-index --quiet HEAD --, then writes the results into AssemblyMetadataAttributes — no new runtime dependency and reflection-trim builds keep working through the existing CliJsonSerializerContext. Missing stamp falls back to bare cdidx v<ver>.
  • Installer reinstall validator was tightened in the same change: it accepts either the bare form or cdidx v<ver> (<metadata>) only and still rejects unparenthesised trailing diagnostic text, so token-enumeration drift cannot hide install regressions.

Fixes #1550

Validation

  • dotnet build CodeIndex.sln — 0 errors / 0 warnings
  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj — 4711 passed, 3 skipped, 0 failed
  • New unit tests cover ConsoleUi.LoadBuildMetadata(), --version human output, --version --json shape, and the unknown-flag error path
  • New installer test asserts the validator accepts cdidx v<ver> (commit ..., built ..., clean); existing trailing-diagnostic test confirms unparenthesised trailing text is still rejected
  • Manually verified cdidx --versioncdidx v1.21.0 (commit 9e2ef14, built 2026-05-16, dirty) and cdidx --version --json{"name":"cdidx","version":"1.21.0","commit":"9e2ef14","build_date":"2026-05-16","dirty":"dirty"}
  • Adversarial review per .codex/workflows/adversarial-review.md: no blocking/actionable issues

Documentation / changelog

  • Bilingual fragment: changelog.d/unreleased/1550.changed.md
  • No standalone doc edits needed — the new flag shape is described in the changelog fragment and the CLI usage banner already documents --version.

Follow-ups

None.

🤖 Generated with Claude Code

Widthdom and others added 2 commits May 16, 2026 02:46
`cdidx --version` now emits `cdidx v<ver> (commit <sha>, built <date>,
<clean|dirty>)` so dev builds are distinguishable from tagged releases
in bug reports. New `--version --json` emits the same fields plus
`name` and `version` for support tooling.

Metadata is captured at build time by a new `StampCdidxBuildMetadata`
MSBuild target that shells out to `git rev-parse --short=7 HEAD` and
`git diff-index --quiet HEAD --`, then writes the results into three
`AssemblyMetadataAttribute`s. ContinueOnError + IgnoreExitCode keep
git-less / non-repo builds working with "unknown" fallbacks, and the
suffix is suppressed when every metadata field is "unknown" so legacy
callers that depend on the bare `cdidx v<ver>` shape (e.g. mocked
binaries) continue to round-trip.

The installer reinstall validator was tightened in the same change:
it now accepts either the bare form or `cdidx v<ver> (<metadata>)`
and continues to reject trailing diagnostic text without parens, so
token-enumeration drift cannot hide install regressions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts:
#	src/CodeIndex/Cli/ProgramRunner.cs
@Widthdom
Widthdom merged commit a754b39 into main May 16, 2026
8 of 11 checks passed
@Widthdom
Widthdom deleted the fix-issue1550 branch May 16, 2026 04:23
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.

--version output omits commit SHA and build metadata

1 participant