We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd5c20a commit dfef54bCopy full SHA for dfef54b
1 file changed
src/utils/vcs.rs
@@ -284,13 +284,14 @@ pub fn git_repo_base_ref(repo: &git2::Repository, remote_name: &str) -> Result<S
284
.to_owned();
285
286
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
- }
+ name.strip_prefix(&expected_prefix)
+ .map(|s| s.to_owned())
+ .ok_or_else(|| {
+ anyhow::anyhow!(
+ "Remote branch name '{name}' does not start with expected prefix \
+ '{expected_prefix}'"
+ )
294
+ })
295
}
296
297
/// Like git_repo_base_repo_name but preserves the original case of the repository name.
0 commit comments