From 4a9b0b92044eba1ac0ffd8c4ac28d9ed3ebde760 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Mon, 22 Dec 2025 10:34:12 -0300 Subject: [PATCH 1/2] Handle long version when git ref is not available. --- cmd/soroban-cli/src/commands/version.rs | 35 ++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/version.rs b/cmd/soroban-cli/src/commands/version.rs index e06970a598..351127d3e1 100644 --- a/cmd/soroban-cli/src/commands/version.rs +++ b/cmd/soroban-cli/src/commands/version.rs @@ -39,8 +39,14 @@ pub fn git() -> &'static str { pub fn long() -> String { let xdr = stellar_xdr::VERSION; + let git_rev = if git().is_empty() { + String::new() + } else { + format!(" ({})", git()) + }; + [ - format!("{} ({})", pkg(), git()), + format!("{}{git_rev}", pkg()), format!( "stellar-xdr {} ({}) xdr curr ({})", @@ -55,3 +61,30 @@ pub fn one_line() -> String { let git = git(); format!("{pkg}#{git}") } + +#[test] +fn test_long_without_git_rev() { + std::env::remove_var("GIT_REVISION"); + let expected = format!( + "{}\nstellar-xdr {} ({})\nxdr curr ({})", + pkg(), + stellar_xdr::VERSION.pkg, + stellar_xdr::VERSION.rev, + stellar_xdr::VERSION.xdr_curr, + ); + assert_eq!(long(), expected); +} + +#[test] +fn test_long_with_git_rev() { + std::env::set_var("GIT_REVISION", "REF"); + let expected = format!( + "{} (REF)\nstellar-xdr {} ({})\nxdr curr ({})", + pkg(), + stellar_xdr::VERSION.pkg, + stellar_xdr::VERSION.rev, + stellar_xdr::VERSION.xdr_curr, + ); + assert_eq!(long(), expected); + std::env::remove_var("GIT_REVISION"); +} From 8ff98c628db78480be22f8911f77b00d447d5a89 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Mon, 22 Dec 2025 10:57:35 -0300 Subject: [PATCH 2/2] Remove tests. --- cmd/soroban-cli/src/commands/version.rs | 27 ------------------------- 1 file changed, 27 deletions(-) diff --git a/cmd/soroban-cli/src/commands/version.rs b/cmd/soroban-cli/src/commands/version.rs index 351127d3e1..7b9670af6d 100644 --- a/cmd/soroban-cli/src/commands/version.rs +++ b/cmd/soroban-cli/src/commands/version.rs @@ -61,30 +61,3 @@ pub fn one_line() -> String { let git = git(); format!("{pkg}#{git}") } - -#[test] -fn test_long_without_git_rev() { - std::env::remove_var("GIT_REVISION"); - let expected = format!( - "{}\nstellar-xdr {} ({})\nxdr curr ({})", - pkg(), - stellar_xdr::VERSION.pkg, - stellar_xdr::VERSION.rev, - stellar_xdr::VERSION.xdr_curr, - ); - assert_eq!(long(), expected); -} - -#[test] -fn test_long_with_git_rev() { - std::env::set_var("GIT_REVISION", "REF"); - let expected = format!( - "{} (REF)\nstellar-xdr {} ({})\nxdr curr ({})", - pkg(), - stellar_xdr::VERSION.pkg, - stellar_xdr::VERSION.rev, - stellar_xdr::VERSION.xdr_curr, - ); - assert_eq!(long(), expected); - std::env::remove_var("GIT_REVISION"); -}