1
- use crate :: commands:: stack:: create_reference:: Anchor ;
2
1
use crate :: error:: Error ;
3
2
use anyhow:: { Context , anyhow} ;
4
3
use but_api_macros:: api_cmd;
5
4
use but_settings:: AppSettings ;
6
- use but_workspace:: branch:: { ReferenceAnchor , ReferencePosition } ;
7
5
use gitbutler_branch_actions:: internal:: PushResult ;
8
6
use gitbutler_branch_actions:: stack:: CreateSeriesRequest ;
9
7
use gitbutler_command_context:: CommandContext ;
@@ -33,11 +31,11 @@ pub mod create_reference {
33
31
pub enum Anchor {
34
32
AtCommit {
35
33
commit_id : HexHash ,
36
- position : but_workspace:: branch:: ReferencePosition ,
34
+ position : but_workspace:: branch:: create_reference :: Position ,
37
35
} ,
38
36
AtReference {
39
37
short_name : String ,
40
- position : but_workspace:: branch:: ReferencePosition ,
38
+ position : but_workspace:: branch:: create_reference :: Position ,
41
39
} ,
42
40
}
43
41
}
@@ -58,17 +56,17 @@ pub fn create_reference(
58
56
let anchor = anchor
59
57
. map ( |anchor| -> Result < _ , Error > {
60
58
Ok ( match anchor {
61
- Anchor :: AtCommit {
59
+ create_reference :: Anchor :: AtCommit {
62
60
commit_id,
63
61
position,
64
- } => but_workspace:: branch:: ReferenceAnchor :: AtCommit {
62
+ } => but_workspace:: branch:: create_reference :: Anchor :: AtCommit {
65
63
commit_id : commit_id. into ( ) ,
66
64
position,
67
65
} ,
68
- Anchor :: AtReference {
66
+ create_reference :: Anchor :: AtReference {
69
67
short_name,
70
68
position,
71
- } => but_workspace:: branch:: ReferenceAnchor :: AtSegment {
69
+ } => but_workspace:: branch:: create_reference :: Anchor :: AtSegment {
72
70
ref_name : Cow :: Owned (
73
71
Category :: LocalBranch
74
72
. to_full_name ( short_name. as_str ( ) )
@@ -103,7 +101,7 @@ pub fn create_branch(
103
101
let project = gitbutler_project:: get ( project_id) ?;
104
102
let ctx = CommandContext :: open ( & project, AppSettings :: load_from_default_path_creating ( ) ?) ?;
105
103
if ctx. app_settings ( ) . feature_flags . ws3 {
106
- use ReferencePosition :: Above ;
104
+ use but_workspace :: branch :: create_reference :: Position :: Above ;
107
105
let mut guard = project. exclusive_worktree_access ( ) ;
108
106
let ( repo, mut meta, graph) = ctx. graph_and_meta_mut_and_repo ( guard. write_permission ( ) ) ?;
109
107
let ws = graph. to_workspace ( ) ?;
@@ -120,19 +118,20 @@ pub fn create_branch(
120
118
121
119
ctx. snapshot_create_dependent_branch ( & request. name , guard. write_permission ( ) )
122
120
. ok ( ) ;
123
- _ = but_workspace:: branch:: create_reference (
124
- new_ref. as_ref ( ) ,
125
- {
126
- let segment = stack. segments . first ( ) . context ( "BUG: no empty stacks" ) ?;
127
- segment
121
+ _ =
122
+ but_workspace:: branch:: create_reference (
123
+ new_ref. as_ref ( ) ,
124
+ {
125
+ let segment = stack. segments . first ( ) . context ( "BUG: no empty stacks" ) ?;
126
+ segment
128
127
. ref_name
129
128
. as_ref ( )
130
- . map ( |rn| ReferenceAnchor :: AtSegment {
129
+ . map ( |rn| but_workspace :: branch :: create_reference :: Anchor :: AtSegment {
131
130
ref_name : Cow :: Borrowed ( rn. as_ref ( ) ) ,
132
131
position : Above ,
133
132
} )
134
133
. or_else ( || {
135
- Some ( ReferenceAnchor :: AtCommit {
134
+ Some ( but_workspace :: branch :: create_reference :: Anchor :: AtCommit {
136
135
commit_id : graph. tip_skip_empty ( segment. id ) ?. id ,
137
136
position : Above ,
138
137
} )
@@ -143,11 +142,11 @@ pub fn create_branch(
143
142
couldn't handle stack_id={stack_id:?}, request={request:?}"
144
143
)
145
144
} ) ?
146
- } ,
147
- & repo,
148
- & ws,
149
- & mut * meta,
150
- ) ?;
145
+ } ,
146
+ & repo,
147
+ & ws,
148
+ & mut * meta,
149
+ ) ?;
151
150
} else {
152
151
// NOTE: locking is built-in here.
153
152
gitbutler_branch_actions:: stack:: create_branch ( & ctx, stack_id, request) ?;
0 commit comments