Skip to content

Commit 98c3267

Browse files
authored
Allow branch creation even if no new name is generated. (#9807)
Thus, instead of defaulting to "Lane", generate a canned name instead. This is different from the previous implementation which somehow succeeds anyway.
1 parent 4b7b37a commit 98c3267

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

crates/but-api/src/commands/virtual_branches.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use gitbutler_stack::{StackId, VirtualBranchesHandle};
2020
use gix::reference::Category;
2121
use serde::Deserialize;
2222

23+
use crate::commands::workspace::{CannedBranchNameParams, canned_branch_name};
2324
use crate::{App, error::Error};
24-
2525
// Parameter structs for all functions
2626

2727
pub fn normalize_branch_name(_app: &App, name: String) -> Result<String, Error> {
@@ -46,7 +46,21 @@ pub fn create_virtual_branch(
4646
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
4747
let ws = graph.to_workspace()?;
4848
let new_ref = Category::LocalBranch
49-
.to_full_name(params.branch.name.as_deref().unwrap_or("Lane"))
49+
.to_full_name(
50+
params
51+
.branch
52+
.name
53+
.map(Ok)
54+
.unwrap_or_else(|| {
55+
canned_branch_name(
56+
app,
57+
CannedBranchNameParams {
58+
project_id: params.project_id,
59+
},
60+
)
61+
})?
62+
.as_str(),
63+
)
5064
.map_err(anyhow::Error::from)?;
5165

5266
let _guard = project.exclusive_worktree_access();

0 commit comments

Comments
 (0)