From d565c9ed0198440b207e3d8232d0f8a30e1b189c Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Thu, 31 Jul 2025 22:59:14 +0800 Subject: [PATCH] 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. --- crates/nu_plugin_gstat/src/gstat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu_plugin_gstat/src/gstat.rs b/crates/nu_plugin_gstat/src/gstat.rs index 917ef3bd51..aeb2c0b81c 100644 --- a/crates/nu_plugin_gstat/src/gstat.rs +++ b/crates/nu_plugin_gstat/src/gstat.rs @@ -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 {