diff --git a/src/agent/onefuzz-agent/build.rs b/src/agent/onefuzz-agent/build.rs index 65a15f8d7a..bec63b58b2 100644 --- a/src/agent/onefuzz-agent/build.rs +++ b/src/agent/onefuzz-agent/build.rs @@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result> { Ok(contents) } -fn print_version(include_sha: bool) -> Result<(), Box> { +fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box> { let mut version = read_file("../../../CURRENT_VERSION")?; let sha = run_cmd(&["git", "rev-parse", "HEAD"])?; @@ -32,7 +32,7 @@ fn print_version(include_sha: bool) -> Result<(), Box> { // if we're a non-release build, check to see if git has // unstaged changes - if run_cmd(&["git", "diff", "--quiet"]).is_err() { + if include_local && run_cmd(&["git", "diff", "--quiet"]).is_err() { version.push('.'); version.push_str("localchanges"); } @@ -47,10 +47,10 @@ fn print_version(include_sha: bool) -> Result<(), Box> { fn main() -> Result<(), Box> { // If we're built off of a tag, we accept CURRENT_VERSION as is. Otherwise // modify it to indicate local build - let include_sha = if let Ok(val) = env::var("GITHUB_REF") { - !val.starts_with("refs/tags/") + let (include_sha, include_local_changes) = if let Ok(val) = env::var("GITHUB_REF") { + (!val.starts_with("refs/tags/"), false) } else { - true + (true, true) }; - print_version(include_sha) + print_version(include_sha, include_local_changes) } diff --git a/src/agent/onefuzz-supervisor/build.rs b/src/agent/onefuzz-supervisor/build.rs index 65a15f8d7a..bec63b58b2 100644 --- a/src/agent/onefuzz-supervisor/build.rs +++ b/src/agent/onefuzz-supervisor/build.rs @@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result> { Ok(contents) } -fn print_version(include_sha: bool) -> Result<(), Box> { +fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box> { let mut version = read_file("../../../CURRENT_VERSION")?; let sha = run_cmd(&["git", "rev-parse", "HEAD"])?; @@ -32,7 +32,7 @@ fn print_version(include_sha: bool) -> Result<(), Box> { // if we're a non-release build, check to see if git has // unstaged changes - if run_cmd(&["git", "diff", "--quiet"]).is_err() { + if include_local && run_cmd(&["git", "diff", "--quiet"]).is_err() { version.push('.'); version.push_str("localchanges"); } @@ -47,10 +47,10 @@ fn print_version(include_sha: bool) -> Result<(), Box> { fn main() -> Result<(), Box> { // If we're built off of a tag, we accept CURRENT_VERSION as is. Otherwise // modify it to indicate local build - let include_sha = if let Ok(val) = env::var("GITHUB_REF") { - !val.starts_with("refs/tags/") + let (include_sha, include_local_changes) = if let Ok(val) = env::var("GITHUB_REF") { + (!val.starts_with("refs/tags/"), false) } else { - true + (true, true) }; - print_version(include_sha) + print_version(include_sha, include_local_changes) } diff --git a/src/proxy-manager/build.rs b/src/proxy-manager/build.rs index 443d0f2340..13b30c0fa4 100644 --- a/src/proxy-manager/build.rs +++ b/src/proxy-manager/build.rs @@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result> { Ok(contents) } -fn print_version(include_sha: bool) -> Result<(), Box> { +fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box> { let mut version = read_file("../../CURRENT_VERSION")?; let sha = run_cmd(&["git", "rev-parse", "HEAD"])?; @@ -32,7 +32,7 @@ fn print_version(include_sha: bool) -> Result<(), Box> { // if we're a non-release build, check to see if git has // unstaged changes - if run_cmd(&["git", "diff", "--quiet"]).is_err() { + if include_local && run_cmd(&["git", "diff", "--quiet"]).is_err() { version.push('.'); version.push_str("localchanges"); } @@ -47,10 +47,10 @@ fn print_version(include_sha: bool) -> Result<(), Box> { fn main() -> Result<(), Box> { // If we're built off of a tag, we accept CURRENT_VERSION as is. Otherwise // modify it to indicate local build - let include_sha = if let Ok(val) = env::var("GITHUB_REF") { - !val.starts_with("refs/tags/") + let (include_sha, include_local_changes) = if let Ok(val) = env::var("GITHUB_REF") { + (!val.starts_with("refs/tags/"), false) } else { - true + (true, true) }; - print_version(include_sha) + print_version(include_sha, include_local_changes) }