Skip to content

Commit 198d1ae

Browse files
Update src/utils/vcs.rs
Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
1 parent ad76996 commit 198d1ae

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/utils/vcs.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,14 @@ pub fn git_repo_base_ref(repo: &git2::Repository, remote_name: &str) -> Result<S
284284
.to_owned();
285285

286286
let expected_prefix = format!("{remote_name}/");
287-
if let Some(branch_name) = name.strip_prefix(&expected_prefix) {
288-
Ok(branch_name.to_owned())
289-
} else {
290-
Err(anyhow::anyhow!(
291-
"Remote branch name '{name}' does not start with expected prefix '{expected_prefix}'"
292-
))
293-
}
287+
name.strip_prefix(&expected_prefix)
288+
.map(|s| s.to_owned())
289+
.ok_or_else(|| {
290+
anyhow::anyhow!(
291+
"Remote branch name '{name}' does not start with expected prefix \
292+
'{expected_prefix}'"
293+
)
294+
})
294295
}
295296

296297
/// Like git_repo_base_repo_name but preserves the original case of the repository name.

0 commit comments

Comments
 (0)