@@ -2,6 +2,7 @@ use std::{collections::HashMap, fmt::Display};
22
33use bstr:: ByteSlice ;
44use but_core:: ref_metadata:: StackId ;
5+ use but_ctx:: Context ;
56use but_hunk_assignment:: HunkAssignment ;
67use gitbutler_command_context:: CommandContext ;
78
@@ -194,7 +195,7 @@ impl CliId {
194195 }
195196 }
196197
197- pub fn from_str ( ctx : & mut CommandContext , s : & str ) -> anyhow:: Result < Vec < Self > > {
198+ pub fn from_str ( ctx : & Context , s : & str ) -> anyhow:: Result < Vec < Self > > {
198199 if s. len ( ) < 2 {
199200 return Err ( anyhow:: anyhow!(
200201 "Id needs to be at least 2 characters long: {}" ,
@@ -203,37 +204,37 @@ impl CliId {
203204 }
204205
205206 // TODO: make callers of this function pass IdDb instead
206- let mut id_db = IdDb :: new ( ctx) ?;
207+ let mut id_db = IdDb :: new ( & ctx. legacy_ctx ( ) ? ) ?;
207208
208209 let mut matches = Vec :: new ( ) ;
209210
210211 // First, try exact branch name match
211- if let Ok ( branch_matches) = id_db. find_branches_by_name ( ctx, s) {
212+ if let Ok ( branch_matches) = id_db. find_branches_by_name ( & ctx. legacy_ctx ( ) ? , s) {
212213 matches. extend ( branch_matches) ;
213214 }
214215
215216 // Then try partial SHA matches (for commits)
216- if let Ok ( commit_matches) = Self :: find_commits_by_sha ( ctx, s) {
217+ if let Ok ( commit_matches) = Self :: find_commits_by_sha ( & ctx. legacy_ctx ( ) ? , s) {
217218 matches. extend ( commit_matches) ;
218219 }
219220
220221 // Then try CliId matching (both prefix and exact)
221222 if s. len ( ) > 2 {
222223 // For longer strings, try prefix matching on CliIds
223224 let mut cli_matches = Vec :: new ( ) ;
224- crate :: status:: all_files ( ctx) ?
225+ crate :: status:: all_files ( & mut ctx. legacy_ctx ( ) ? ) ?
225226 . into_iter ( )
226227 . filter ( |id| id. matches_prefix ( s) )
227228 . for_each ( |id| cli_matches. push ( id) ) ;
228- crate :: status:: all_committed_files ( ctx) ?
229+ crate :: status:: all_committed_files ( & mut ctx. legacy_ctx ( ) ? ) ?
229230 . into_iter ( )
230231 . filter ( |id| id. matches_prefix ( s) )
231232 . for_each ( |id| cli_matches. push ( id) ) ;
232- crate :: status:: all_branches ( ctx) ?
233+ crate :: status:: all_branches ( & ctx. legacy_ctx ( ) ? ) ?
233234 . into_iter ( )
234235 . filter ( |id| id. matches_prefix ( s) )
235236 . for_each ( |id| cli_matches. push ( id) ) ;
236- crate :: utils:: commits:: all_commits ( ctx) ?
237+ crate :: utils:: commits:: all_commits ( & ctx. legacy_ctx ( ) ? ) ?
237238 . into_iter ( )
238239 . filter ( |id| id. matches_prefix ( s) )
239240 . for_each ( |id| cli_matches. push ( id) ) ;
@@ -244,19 +245,19 @@ impl CliId {
244245 } else {
245246 // For 2-character strings, try exact CliId matching
246247 let mut cli_matches = Vec :: new ( ) ;
247- crate :: status:: all_files ( ctx) ?
248+ crate :: status:: all_files ( & mut ctx. legacy_ctx ( ) ? ) ?
248249 . into_iter ( )
249250 . filter ( |id| id. matches ( s) )
250251 . for_each ( |id| cli_matches. push ( id) ) ;
251- crate :: status:: all_committed_files ( ctx) ?
252+ crate :: status:: all_committed_files ( & mut ctx. legacy_ctx ( ) ? ) ?
252253 . into_iter ( )
253254 . filter ( |id| id. matches ( s) )
254255 . for_each ( |id| cli_matches. push ( id) ) ;
255- crate :: status:: all_branches ( ctx) ?
256+ crate :: status:: all_branches ( & ctx. legacy_ctx ( ) ? ) ?
256257 . into_iter ( )
257258 . filter ( |id| id. matches ( s) )
258259 . for_each ( |id| cli_matches. push ( id) ) ;
259- crate :: utils:: commits:: all_commits ( ctx) ?
260+ crate :: utils:: commits:: all_commits ( & ctx. legacy_ctx ( ) ? ) ?
260261 . into_iter ( )
261262 . filter ( |id| id. matches ( s) )
262263 . for_each ( |id| cli_matches. push ( id) ) ;
0 commit comments