@@ -29,6 +29,12 @@ pub fn handle(cmd: &Subcommands, repo_path: &Path, _json: bool) -> anyhow::Resul
29
29
branch_name,
30
30
anchor,
31
31
} => {
32
+ // Get branch name or use canned name
33
+ let branch_name = if let Some ( name) = branch_name {
34
+ name. clone ( )
35
+ } else {
36
+ but_api:: workspace:: canned_branch_name ( project. id ) ?
37
+ } ;
32
38
if let Some ( anchor_str) = anchor {
33
39
// Use the new create_reference API when anchor is provided
34
40
let ctx = CommandContext :: open (
@@ -50,13 +56,6 @@ pub fn handle(cmd: &Subcommands, repo_path: &Path, _json: bool) -> anyhow::Resul
50
56
}
51
57
let anchor_id = & anchor_ids[ 0 ] ;
52
58
53
- // Get branch name or use canned name
54
- let branch_name = if let Some ( name) = branch_name {
55
- name. clone ( )
56
- } else {
57
- but_api:: workspace:: canned_branch_name ( project. id ) ?
58
- } ;
59
-
60
59
// Create the anchor for create_reference
61
60
let anchor = match anchor_id {
62
61
crate :: id:: CliId :: Commit { oid } => {
@@ -85,19 +84,16 @@ pub fn handle(cmd: &Subcommands, repo_path: &Path, _json: bool) -> anyhow::Resul
85
84
anchor,
86
85
} ;
87
86
but_api:: stack:: create_reference ( project. id , request) ?;
88
- println ! ( "Created branch {branch_name}" ) ;
89
- Ok ( ( ) )
90
87
} else {
91
88
// Create an independent branch
92
- let req = gitbutler_branch:: BranchCreateRequest {
93
- name : branch_name. clone ( ) ,
94
- ownership : None ,
95
- order : None ,
96
- selected_for_changes : None ,
89
+ let request = but_api:: stack:: create_reference:: Request {
90
+ new_name : branch_name. clone ( ) ,
91
+ anchor : None ,
97
92
} ;
98
- but_api:: virtual_branches:: create_virtual_branch ( project. id , req) ?;
99
- Ok ( ( ) )
93
+ but_api:: stack:: create_reference ( project. id , request) ?;
100
94
}
95
+ println ! ( "Created branch {branch_name}" ) ;
96
+ Ok ( ( ) )
101
97
}
102
98
}
103
99
}
0 commit comments