File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ impl PrepareFetch {
3434 self . shallow = shallow;
3535 self
3636 }
37+
38+ /// Apply the given configuration `values` early to allow affecting the repository instantiation phase.
39+ /// The configuration is marked with [source API][gix_config::Source::Api].
40+ pub fn config_overrides ( mut self , values : impl IntoIterator < Item = impl Into < BString > > ) -> Self {
41+ self . api_config_overrides = values. into_iter ( ) . map ( Into :: into) . collect ( ) ;
42+ self
43+ }
3744}
3845
3946/// Consumption
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ pub enum Error {
1818 RemoteConnection ( #[ source] Box < dyn std:: error:: Error + Send + Sync > ) ,
1919 #[ error( transparent) ]
2020 RemoteName ( #[ from] crate :: config:: remote:: symbolic_name:: Error ) ,
21+ #[ error( transparent) ]
22+ ParseConfig ( #[ from] crate :: config:: overrides:: Error ) ,
23+ #[ error( transparent) ]
24+ ApplyConfig ( #[ from] crate :: config:: Error ) ,
2125 #[ error( "Failed to load repo-local git configuration before writing" ) ]
2226 LoadConfig ( #[ from] gix_config:: file:: init:: from_paths:: Error ) ,
2327 #[ error( "Failed to store configured remote in memory" ) ]
@@ -75,6 +79,10 @@ impl PrepareFetch {
7579 . as_mut ( )
7680 . expect ( "user error: multiple calls are allowed only until it succeeds" ) ;
7781
82+ let mut snapshot = repo. config_snapshot_mut ( ) ;
83+ snapshot. append_config ( self . api_config_overrides . as_slice ( ) , gix_config:: Source :: Api ) ?;
84+ snapshot. commit ( ) ?;
85+
7886 let remote_name = match self . remote_name . as_ref ( ) {
7987 Some ( name) => name. to_owned ( ) ,
8088 None => repo
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub struct PrepareFetch {
2020 repo : Option < crate :: Repository > ,
2121 /// The name of the remote, which defaults to `origin` if not overridden.
2222 remote_name : Option < BString > ,
23+ /// Additional config `values` that are applied in-memory before starting the fetch process.
24+ api_config_overrides : Vec < BString > ,
2325 /// A function to configure a remote prior to fetching a pack.
2426 configure_remote : Option < ConfigureRemoteFn > ,
2527 /// A function to configure a connection before using it.
@@ -126,6 +128,7 @@ impl PrepareFetch {
126128 #[ cfg( any( feature = "async-network-client" , feature = "blocking-network-client" ) ) ]
127129 fetch_options : Default :: default ( ) ,
128130 repo : Some ( repo) ,
131+ api_config_overrides : Vec :: new ( ) ,
129132 remote_name : None ,
130133 configure_remote : None ,
131134 #[ cfg( any( feature = "async-network-client" , feature = "blocking-network-client" ) ) ]
You can’t perform that action at this time.
0 commit comments