mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-09 08:41:34 +00:00
make version.localchanges match API logic (#62)
This commit is contained in:
parent
eae0f42938
commit
d2ee7e5e7d
@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result<String, Box<dyn Error>> {
|
||||
Ok(contents)
|
||||
}
|
||||
|
||||
fn print_version(include_sha: bool) -> Result<(), Box<dyn Error>> {
|
||||
fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
|
||||
// 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<dyn Error>> {
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
// 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)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result<String, Box<dyn Error>> {
|
||||
Ok(contents)
|
||||
}
|
||||
|
||||
fn print_version(include_sha: bool) -> Result<(), Box<dyn Error>> {
|
||||
fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
|
||||
// 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<dyn Error>> {
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
// 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)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fn read_file(filename: &str) -> Result<String, Box<dyn Error>> {
|
||||
Ok(contents)
|
||||
}
|
||||
|
||||
fn print_version(include_sha: bool) -> Result<(), Box<dyn Error>> {
|
||||
fn print_version(include_sha: bool, include_local: bool) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
|
||||
// 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<dyn Error>> {
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
// 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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user