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 {
34
34
self . shallow = shallow;
35
35
self
36
36
}
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
+ }
37
44
}
38
45
39
46
/// Consumption
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ pub enum Error {
18
18
RemoteConnection ( #[ source] Box < dyn std:: error:: Error + Send + Sync > ) ,
19
19
#[ error( transparent) ]
20
20
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 ) ,
21
25
#[ error( "Failed to load repo-local git configuration before writing" ) ]
22
26
LoadConfig ( #[ from] gix_config:: file:: init:: from_paths:: Error ) ,
23
27
#[ error( "Failed to store configured remote in memory" ) ]
@@ -75,6 +79,10 @@ impl PrepareFetch {
75
79
. as_mut ( )
76
80
. expect ( "user error: multiple calls are allowed only until it succeeds" ) ;
77
81
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
+
78
86
let remote_name = match self . remote_name . as_ref ( ) {
79
87
Some ( name) => name. to_owned ( ) ,
80
88
None => repo
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub struct PrepareFetch {
20
20
repo : Option < crate :: Repository > ,
21
21
/// The name of the remote, which defaults to `origin` if not overridden.
22
22
remote_name : Option < BString > ,
23
+ /// Additional config `values` that are applied in-memory before starting the fetch process.
24
+ api_config_overrides : Vec < BString > ,
23
25
/// A function to configure a remote prior to fetching a pack.
24
26
configure_remote : Option < ConfigureRemoteFn > ,
25
27
/// A function to configure a connection before using it.
@@ -126,6 +128,7 @@ impl PrepareFetch {
126
128
#[ cfg( any( feature = "async-network-client" , feature = "blocking-network-client" ) ) ]
127
129
fetch_options : Default :: default ( ) ,
128
130
repo : Some ( repo) ,
131
+ api_config_overrides : Vec :: new ( ) ,
129
132
remote_name : None ,
130
133
configure_remote : None ,
131
134
#[ cfg( any( feature = "async-network-client" , feature = "blocking-network-client" ) ) ]
You can’t perform that action at this time.
0 commit comments