feat(version): show short SHA and commit date on default version line (FJ-25) #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/version-sha-date-FJ-25"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
FJ-25: surface the short git SHA and commit date on the default
fj versionline.Before, the default line printed only
fj v{version}; the SHA (baked since FJ-15) showed only under-v/--jsonand no date was baked at all. Now:A plain
cargo buildfrom source has no baked metadata, so its line stays the cleanfj v0.7.1(no parenthetical, no "unknown").Changes
crates/fj/build.rs: bakeFJ_COMMIT_DATE/FJ_BUILD_DATEfromCOMMIT_DATE/BUILD_DATEenv (sameoption_envpattern asGIT_SHA), withrerun-if-env-changedfor both. build.rs cannot derive these itself because the Docker build does not copy.git, so CI passes them as build-args exactly the wayGIT_SHAalready does.crates/fj/src/version.rs: default line shows({short_sha} {commit_date_day})only when both SHA and commit date are baked; verbose adds full RFC3339commit date/build date; JSON gainscommit_date/build_date.fj version --checkis unchanged..forgejo/workflows/build-binary.ymlandbuild-binary-windows.yml: computecommit_date(git show -s --format=%cI HEAD) and reuse the existingbuilt_atvalue asbuild_date, then pass both via--build-arg.oci-build/Dockerfileandoci-build/Dockerfile.windows: accept the new ARGs and ENV them into the real-source build stage.Verification
cargo build:fj versionprintsfj v0.7.1(unchanged), JSON hascommit_date/build_date=unknown.GIT_SHA/COMMIT_DATE/BUILD_DATEbaked: default linefj v0.7.1 (0ac836df 2026-05-28), verbose shows both full RFC3339 dates, JSON carries both fields.cargo fmt --checkandcargo clippyclean (no new warnings).Note on issue State
Committed with a bare
#FJ-25reference (noState Donetrailer) per the repo's commit policy: the Forgejo VCS integration applies trailer commands at push time, not merge time, so aState Donetrailer would resolve the issue while this PR is still open. State is set to Done explicitly after a human merges.🤖 Generated with Claude Code
The default `fj version` line printed only `fj v{version}`, hiding the git SHA (baked since FJ-15 but shown only under `-v`/`--json`) and carrying no date at all. Surface the short SHA and commit date on the first line for CI builds while keeping a plain `cargo build` output clean. build.rs now bakes `FJ_COMMIT_DATE`/`FJ_BUILD_DATE` from `COMMIT_DATE`/`BUILD_DATE` env using the same `option_env` pattern as `GIT_SHA`, with `rerun-if-env-changed` for both. build.rs cannot derive these itself because the Docker build does not copy `.git`, so CI passes them as build-args exactly the way `GIT_SHA` already flows. version.rs default line prints `{name} v{version} ({short_sha} {commit_date_day})` only when both the SHA and commit date are baked; otherwise it stays the unchanged `{name} v{version}` (no parenthetical, no "unknown"). Verbose adds full RFC3339 `commit date` and `build date` lines; JSON gains `commit_date` and `build_date` fields. `fj version --check` is unchanged. Both build-binary workflows compute `commit_date` (`git show -s --format=%cI HEAD`) and reuse the existing `built_at` value as `build_date`, then pass both as `--build-arg`. Both Dockerfiles accept the new ARGs and ENV them into the real-source build stage. #FJ-25 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>