Skip to content

fix: short version sha should be length = 8#247

Open
cuiweixie wants to merge 1 commit intomainfrom
wesley/fix/version_short_sha
Open

fix: short version sha should be length = 8#247
cuiweixie wants to merge 1 commit intomainfrom
wesley/fix/version_short_sha

Conversation

@cuiweixie
Copy link
Copy Markdown
Contributor

before this pr look like:

xlayer-reth-node Version: 0.1.0-dev (6723ce3)
Upstream Reth Version: 9b91afa4
Build Timestamp: 2026-03-18T10:53:16.524852000Z
Build Features:
Build Profile: debug

6723ce3 is length of 7.
after this pr:

xlayer-reth-node Version: 0.1.0-dev (be14d8be)
Upstream Reth Version: d6324d63
Build Timestamp: 2026-04-02T08:33:40.454248000Z
Build Features:
Build Profile: debug

be14d8b is length of 8.

@cuiweixie cuiweixie requested a review from Vui-Chee April 2, 2026 08:43
@cuiweixie
Copy link
Copy Markdown
Contributor Author

@claude reivew this pr.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Claude finished @cuiweixie's task in 1m 7s —— View job


PR Review: fix: short version sha should be length = 8

  • Gathering context
  • Reviewing changed files
  • Posting review feedback

Summary

Simple one-line fix in crates/version/build.rs: changes &sha[0..7]&sha[0..8] to produce an 8-character short SHA.

What's Good

The fix correctly resolves an inconsistency in the file. Line 29 (VERGEN_GIT_SHA_SHORT) was already using &sha[..8] (8 chars), but sha_short on line 21 was only taking 7 chars — meaning the version string displayed a 7-char SHA while the env var exposed an 8-char one. This unifies them.

Potential Concern: not_on_tag check

// crates/version/build.rs:24
let not_on_tag = env::var("VERGEN_GIT_DESCRIBE")?.ends_with(&format!("-g{sha_short}"));

VERGEN_GIT_DESCRIBE comes from git describe --tags --long, which by default appends a 7-character short SHA (e.g. v0.1.0-3-gabcdef1). Now that sha_short is 8 chars, "-g{sha_short}" would be "-gabcdef12" (8 chars after g), which may not match the 7-char SHA in the describe output.

If this mismatch occurs, not_on_tag would always be false, meaning the -dev version suffix would only be added when the working tree is dirty — not when there are commits after a tag. Worth verifying that the -dev suffix still appears correctly on non-tagged commits.

Note: vergen_git2 may configure git describe to use the same short SHA length as VERGEN_GIT_SHA, in which case this would not be an issue. Checking the vergen_git2 docs or testing on a commit between tags would confirm.

Minor: Duplicate slice

Lines 21 and 29 both slice sha to 8 chars:

// line 21
let sha_short = &sha[0..8];
// ...
// line 29
println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={}", &sha[..8]);

Line 29 could just use sha_short instead of re-slicing, e.g.:

println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={sha_short}");

This is cosmetic, not blocking.

Verdict

Approve with minor note — the core fix is correct and eliminates the 7-vs-8 inconsistency. Recommend verifying the not_on_tag behavior on a non-tagged commit to confirm the -dev suffix still works as expected.

@Vui-Chee
Copy link
Copy Markdown
Contributor

Vui-Chee commented Apr 2, 2026

@ci

@Vui-Chee
Copy link
Copy Markdown
Contributor

Vui-Chee commented Apr 2, 2026

⏳ Claude is processing your request...

@Vui-Chee
Copy link
Copy Markdown
Contributor

Vui-Chee commented Apr 2, 2026

@ci

@XLayer-Bot
Copy link
Copy Markdown

⏳ Robot is processing your request...

@XLayer-Bot
Copy link
Copy Markdown

XLayer Reth CI failed for commit 34c43009bcca0b4b9b7b67a6927716efb8c6b6b9

Step Result
format-check failure
sweep-check skipped
clippy skipped
tests skipped

View run

@okx okx deleted a comment from XLayer-Bot Apr 2, 2026
@Vui-Chee
Copy link
Copy Markdown
Contributor

Vui-Chee commented Apr 2, 2026

@ci

@XLayer-Bot
Copy link
Copy Markdown

⏳ Robot is processing your request...

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.

3 participants