Skip to content

feat(cli): include git hash in fe --version output#1363

Open
0xWeakSheep wants to merge 7 commits intoargotorg:masterfrom
0xWeakSheep:codex/issue-1338-version-git-hash
Open

feat(cli): include git hash in fe --version output#1363
0xWeakSheep wants to merge 7 commits intoargotorg:masterfrom
0xWeakSheep:codex/issue-1338-version-git-hash

Conversation

@0xWeakSheep
Copy link
Copy Markdown
Contributor

Summary

This PR resolves #1338 by adding the current git short hash to fe --version.

Before:

  • fe 26.0.0-alpha.7

After:

  • fe 26.0.0-alpha.7 (6d15b3851) (example)

What changed

  • Added crates/fe/build.rs:
    • Reads git rev-parse --short HEAD at build time.
    • Exposes it as FE_GIT_HASH via cargo:rustc-env.
    • Supports overriding via FE_GIT_HASH environment variable.
  • Updated crates/fe/src/main.rs:
    • Added cli_version() to format version output.
    • Switched clap metadata from #[command(version)] to #[command(version = cli_version())].

Validation

  • Ran:
    • cargo run -q -p fe -- --version
  • Verified output now includes the git short hash.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06f2d18b75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/build.rs
use std::process::Command;

fn main() {
println!("cargo:rerun-if-changed=.git/HEAD");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recompute git hash when HEAD commit changes

cargo:rerun-if-changed=.git/HEAD does not reliably invalidate this build script for new commits, so FE_GIT_HASH can go stale and fe --version can report an old hash. In this crate (crates/fe), .git/HEAD is not the repo’s HEAD file, and even if the path were corrected, HEAD’s contents usually stay unchanged while advancing commits on the same branch; as a result, rebuilding after a new commit (without touching source files) may keep the previous hash.

Useful? React with 👍 / 👎.

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.

cli: add git hash to fe version info

1 participant