Skip to content

Commit 57cc2dd

Browse files
committed
apply fix for failing test
1 parent 1059c76 commit 57cc2dd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn determine_nex_tag(
4444
return Err(incremented_tag_result.err().unwrap());
4545
}
4646
let incremented_tag = incremented_tag_result?;
47-
return Ok(incremented_tag);
47+
Ok(incremented_tag)
4848
}
4949
VersionType::PreRelease => {
5050
let suffix = next_tag_request.suffix.unwrap();
@@ -69,20 +69,18 @@ pub fn determine_nex_tag(
6969

7070
if found_suffix_tag {
7171
// If the suffix is found, only increment the suffix
72-
// So strip of the suffix and leave it at that
73-
let tag = last_tag.split('-').next().unwrap();
74-
let last_suffix = last_tag.split('-').last().unwrap();
75-
let last_suffix = last_suffix.parse::<i32>().unwrap();
76-
let incremented_suffix = last_suffix + 1;
77-
return Ok(format!("{}-{}-{}", tag, suffix, incremented_suffix));
72+
// We split the tag at the last hyphen to separate the base from the number.
73+
let (base, number_str) = last_tag.rsplit_once('-').unwrap();
74+
let number = number_str.parse::<i32>().unwrap();
75+
Ok(format!("{}-{}", base, number + 1))
7876
} else {
7977
// increment the patch version, and add the suffix with 0
8078
let incremented_tag_result = increment_tag(last_tag);
8179
if incremented_tag_result.is_err() {
8280
return Err(incremented_tag_result.err().unwrap());
8381
}
8482
let incremented_tag = incremented_tag_result?;
85-
return Ok(format!("{}-{}-0", incremented_tag, suffix));
83+
Ok(format!("{}-{}-0", incremented_tag, suffix))
8684
}
8785
}
8886
VersionType::PreReleaseCommit => {
@@ -100,7 +98,7 @@ pub fn determine_nex_tag(
10098
let incremented_tag = incremented_tag_result?;
10199
let commit_sha = get_current_commit_sha(next_tag_request.path.as_str())
102100
.expect("Could not get commit sha");
103-
return Ok(format!("{}-{}", incremented_tag, commit_sha));
101+
Ok(format!("{}-{}", incremented_tag, commit_sha))
104102
}
105103
}
106104
}
@@ -147,7 +145,7 @@ pub fn query_git_tags(
147145
.output()
148146
.expect("Failed to execute git tag command");
149147

150-
debug!("Output: {}", String::from(output.status.to_string()));
148+
debug!("Output: {}", output.status.to_string());
151149
let stdout = String::from_utf8(output.stdout)?;
152150
debug!("Git tags: {}", stdout);
153151
debug!("Error: {}", String::from_utf8(output.stderr)?);

0 commit comments

Comments
 (0)