Skip to content

Commit e895fef

Browse files
committed
Allow configuting the Repository object created by PrepareFetch.
1 parent 115c993 commit e895fef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

gix/src/clone/access.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{bstr::BString, clone::PrepareFetch, Repository};
1+
use crate::{bstr::BString, clone::PrepareFetch, Repository, config::SnapshotMut};
22

33
/// Builder
44
impl PrepareFetch {
@@ -34,6 +34,16 @@ impl PrepareFetch {
3434
self.shallow = shallow;
3535
self
3636
}
37+
38+
/// Configure the repository's configuration before the fetch operation is performed.
39+
pub fn configure(mut self, f: impl FnOnce(&mut SnapshotMut<'_>) -> Result<(), Box<dyn std::error::Error + Send + Sync>>) -> Result<Self, Box<dyn std::error::Error + Send + Sync>> {
40+
if let Some(repo) = self.repo.as_mut() {
41+
let mut snapshot = repo.config_snapshot_mut();
42+
f(&mut snapshot)?;
43+
snapshot.commit()?;
44+
}
45+
Ok(self)
46+
}
3747
}
3848

3949
/// Consumption

0 commit comments

Comments
 (0)