Fix commit ID hex formatting in gstat (#16309)

Fix commit ID hex formatting in gstat, closes #16307 

Leading zeros are preserved, maintaining the correct hex representation

This issue is relatively easy to fix, but it's not very easy to verify.
However, I have already tested several scenarios, it works for commit
sha like `000baeef`, `000003c7` and `00000002` etc.
This commit is contained in:
Justin Ma
2025-07-31 22:59:14 +08:00
committed by GitHub
parent 18d5d8aae1
commit d565c9ed01

View File

@ -294,7 +294,7 @@ impl Stats {
if let Ok(commit) = head.peel_to_commit() {
let mut id = String::new();
for byte in &commit.id().as_bytes()[..4] {
write!(&mut id, "{byte:x}").unwrap();
write!(&mut id, "{byte:02x}").unwrap();
}
id
} else {