Skip to content

Commit

Permalink
refactor(release-helper): move out multiple version flag check
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Nov 24, 2023
1 parent c6e9ad0 commit 9e2e70b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion release-helper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ options are: --major, --minor, --patch"
);
return;
}
if (*major || *minor) && *patch || (*major && *minor) {
if enabled_version_flag_count(*major, *minor, *patch) > 1 {
println!("Only one version flag should be specified.");
return;
}
Expand Down Expand Up @@ -101,6 +101,14 @@ fn check_running_directory() -> bool {
true
}

fn enabled_version_flag_count(major: bool, minor: bool, patch: bool) -> i32 {
let mut count = 0;
if major { count += 1; }
if minor { count += 1; }
if patch { count += 1; }
return count;
}

fn today_iso8601() -> String {
let today =
OffsetDateTime::now_local().expect("Could not determine the UTC offset on this system!");
Expand Down

0 comments on commit 9e2e70b

Please sign in to comment.