Stamp commit SHA / build date / dirty flag into --version (#1550) - #2193
Merged
Conversation
`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
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.
Summary
cdidx --versionnow 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. Newcdidx --version --jsonemits{name, version, commit, build_date, dirty}for support tooling.StampCdidxBuildMetadataMSBuild target that shells out togit rev-parse --short=7 HEADandgit diff-index --quiet HEAD --, then writes the results intoAssemblyMetadataAttributes — no new runtime dependency and reflection-trim builds keep working through the existingCliJsonSerializerContext. Missing stamp falls back to barecdidx v<ver>.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 warningsdotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj— 4711 passed, 3 skipped, 0 failedConsoleUi.LoadBuildMetadata(),--versionhuman output,--version --jsonshape, and the unknown-flag error pathcdidx v<ver> (commit ..., built ..., clean); existing trailing-diagnostic test confirms unparenthesised trailing text is still rejectedcdidx --version→cdidx v1.21.0 (commit 9e2ef14, built 2026-05-16, dirty)andcdidx --version --json→{"name":"cdidx","version":"1.21.0","commit":"9e2ef14","build_date":"2026-05-16","dirty":"dirty"}.codex/workflows/adversarial-review.md: no blocking/actionable issuesDocumentation / changelog
changelog.d/unreleased/1550.changed.md--version.Follow-ups
None.
🤖 Generated with Claude Code