Repository navigation
feat: show commit hash, branch, commit count and build date in --version - #34
Merged
Merged
Conversation
comline -V stays the bare CARGO_PKG_VERSION. comline --version now also shows: commit-hash: d9ccd73(-dirty) commit-branch: main commit-count: 78 build-date: 2026-10-03T13:26:54Z build.rs's new emit_version_info captures these via git/date at build time (cargo:rustc-env=...), degrading each independently to "unknown" rather than failing the build - a source tarball with no .git, or a machine with no git/date on PATH, still produces a working binary. "-dirty" is appended to the hash when `git status --porcelain` is non-empty at build time. The long_version string is built at runtime in main.rs (via option_env!, never a hard env!) rather than through the #[command(long_version = ...)] derive attribute on Cli - build.rs itself compiles src/cli.rs via #[path] for man-page/completion generation, before it has emitted these env vars for the real binary, so a const baked in by that attribute would need env! there too and hard-fail that earlier compilation.
Kinflou
pushed a commit
that referenced
this pull request
Oct 3, 2026
Slipped through in the --version feature (#34) - this repo's CI runs cargo fmt --check, caught here when it ran on this PR's otherwise- unrelated branch.
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
comline -Vstays the bareCARGO_PKG_VERSION.comline --versionnow also shows:(
-dirtyappended to the hash when the working tree had uncommitted changes at build time.)build.rs's newemit_version_infocaptures these viagit/dateat build time (cargo:rustc-env=...), degrading each field independently to"unknown"rather than failing the build — a source tarball with no.git, or a machine with nogit/dateon PATH, still produces a working binary.main.rs(viaoption_env!, never a hardenv!), not through the#[command(long_version = ...)]derive attribute —build.rsitself compilessrc/cli.rsvia#[path]for man-page/completion generation, before it has emitted these env vars for the real binary, so aconstbaked in by that attribute would needenv!there too and hard-fail that earlier compilation.Test plan
cargo build/cargo test— clean, 46 tests passingcomline -Vvscomline --version— confirmed the split abovebuild.rs's original job) still works