feat(version): show short SHA and commit date on default version line (FJ-25) #28

Merged
David merged 2 commits from feat/version-sha-date-FJ-25 into main 2026-05-29 02:15:09 +02:00
Owner

What

FJ-25: surface the short git SHA and commit date on the default fj version line.

Before, the default line printed only fj v{version}; the SHA (baked since FJ-15) showed only under -v/--json and no date was baked at all. Now:

$ fj version
fj v0.7.1 (0ac836df 2026-05-28)
Check for a new version with `fj version --check`

A plain cargo build from source has no baked metadata, so its line stays the clean fj v0.7.1 (no parenthetical, no "unknown").

Changes

  • crates/fj/build.rs: bake FJ_COMMIT_DATE/FJ_BUILD_DATE from COMMIT_DATE/BUILD_DATE env (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 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 RFC3339 commit date / build date; JSON gains commit_date / build_date. fj version --check is unchanged.
  • .forgejo/workflows/build-binary.yml and build-binary-windows.yml: compute commit_date (git show -s --format=%cI HEAD) and reuse the existing built_at value as build_date, then pass both via --build-arg.
  • oci-build/Dockerfile and oci-build/Dockerfile.windows: accept the new ARGs and ENV them into the real-source build stage.

Verification

  • Plain cargo build: fj version prints fj v0.7.1 (unchanged), JSON has commit_date/build_date = unknown.
  • With GIT_SHA/COMMIT_DATE/BUILD_DATE baked: default line fj v0.7.1 (0ac836df 2026-05-28), verbose shows both full RFC3339 dates, JSON carries both fields.
  • cargo fmt --check and cargo clippy clean (no new warnings).

Note on issue State

Committed with a bare #FJ-25 reference (no State Done trailer) per the repo's commit policy: the Forgejo VCS integration applies trailer commands at push time, not merge time, so a State Done trailer would resolve the issue while this PR is still open. State is set to Done explicitly after a human merges.

🤖 Generated with Claude Code

## What FJ-25: surface the short git SHA and commit date on the default `fj version` line. Before, the default line printed only `fj v{version}`; the SHA (baked since FJ-15) showed only under `-v`/`--json` and no date was baked at all. Now: ``` $ fj version fj v0.7.1 (0ac836df 2026-05-28) Check for a new version with `fj version --check` ``` A plain `cargo build` from source has no baked metadata, so its line stays the clean `fj v0.7.1` (no parenthetical, no "unknown"). ## Changes - `crates/fj/build.rs`: bake `FJ_COMMIT_DATE`/`FJ_BUILD_DATE` from `COMMIT_DATE`/`BUILD_DATE` env (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 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 RFC3339 `commit date` / `build date`; JSON gains `commit_date` / `build_date`. `fj version --check` is unchanged. - `.forgejo/workflows/build-binary.yml` and `build-binary-windows.yml`: compute `commit_date` (`git show -s --format=%cI HEAD`) and reuse the existing `built_at` value as `build_date`, then pass both via `--build-arg`. - `oci-build/Dockerfile` and `oci-build/Dockerfile.windows`: accept the new ARGs and ENV them into the real-source build stage. ## Verification - Plain `cargo build`: `fj version` prints `fj v0.7.1` (unchanged), JSON has `commit_date`/`build_date` = `unknown`. - With `GIT_SHA`/`COMMIT_DATE`/`BUILD_DATE` baked: default line `fj v0.7.1 (0ac836df 2026-05-28)`, verbose shows both full RFC3339 dates, JSON carries both fields. - `cargo fmt --check` and `cargo clippy` clean (no new warnings). ## Note on issue State Committed with a bare `#FJ-25` reference (no `State Done` trailer) per the repo's commit policy: the Forgejo VCS integration applies trailer commands at push time, not merge time, so a `State Done` trailer would resolve the issue while this PR is still open. State is set to Done explicitly after a human merges. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(version): show short SHA and commit date on default version line (FJ-25)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 37s
3c29eea558
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>
Merge branch 'main' into feat/version-sha-date-FJ-25
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / fmt + clippy + build + tests (pull_request) Successful in 39s
57008dc9ab
David merged commit 38290a06f0 into main 2026-05-29 02:15:09 +02:00
David deleted branch feat/version-sha-date-FJ-25 2026-05-29 02:15:09 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/forgejo-cli!28
No description provided.