Skip to content

cli: show the git commit in --version - #991

Merged
rgushchin merged 1 commit into
sashiko-dev:mainfrom
sendaoYan:version-git-sha
Dec 3, 2026
Merged

rgushchin merged 1 commit into
sashiko-dev:mainfrom
sendaoYan:version-git-sha

Conversation

@sendaoYan

Copy link
Copy Markdown
Contributor

sashiko --version prints only the crate version, so a locally built binary
cannot be correlated with the commit it came from. build.rs already embeds
GIT_HASH; surface it in the version string:

sashiko 0.9.7 (git f143da484cb2…)

so run scripts and operators can record exactly which commit a binary was
built from. Closes #987.

@sashiko-bot

sashiko-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

Sashiko review

Commit 1/1 — e610bb13 cli: show the git commit in --version

  • [LOW] src/main.rs: Cli unconditionally formats --version with
    (git GIT_HASH). When git rev-parse HEAD fails, such as in release source
    archives from scripts/package-release.sh or cargo install builds, build.rs
    main() falls back to CARGO_PKG_VERSION or unknown, so sashiko --version
    prints output like 0.9.7 (git 0.9.7). Export a separate CLI version string
    from build.rs that appends (git ) only when git succeeds, leaving
    GIT_HASH unchanged for existing consumers.

  • [LOW] src/bin/sashiko-cli.rs: Cli still uses bare #[command(version)], so
    sashiko-cli --version prints only the crate version without the git commit
    hash. Both binaries are built from the same package and packaged together,
    so locally built sashiko-cli binaries still cannot be tied to a commit.
    Share one compile-time version string between src/main.rs and
    src/bin/sashiko-cli.rs.

Full review and stage logs on sashiko.sashiko.dev

sashiko --version prints only the crate version, so a locally built binary
cannot be correlated with the commit it came from. build.rs already embeds
GIT_HASH; surface it in the version string so run scripts and operators can
record exactly which commit a binary was built from.

Closes: sashiko-dev#987
Signed-off-by: Sendao Yan <yansendao@126.com>
@sashiko-bot

sashiko-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

Sashiko review — v2

✓ No issues found across 1 commit.

Full review log on sashiko.sashiko.dev

@rgushchin
rgushchin merged commit 643d992 into sashiko-dev:main Dec 3, 2026
1 check passed
@sendaoYan
sendaoYan deleted the version-git-sha branch December 4, 2026 00:02
@sendaoYan

Copy link
Copy Markdown
Contributor Author

@rgushchin Thanks for the review and merge.

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.

show the git commit in sashiko --version

2 participants