Skip to content

Commit 900ae56

Browse files
committed
Add fetch_changes_with_options() using gitoxide
1 parent 00e6875 commit 900ae56

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/index/diff/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,29 @@ impl Index {
268268
Ok(changes)
269269
}
270270

271+
/// Return all `Change`s that are observed between the last time this method was called
272+
/// and the latest state of the `crates.io` index repository, which is obtained by fetching
273+
/// the remote called `origin`.
274+
/// The `last_seen_reference()` will be created or adjusted to point to the latest fetched
275+
/// state, which causes this method to have a different result each time it is called.
276+
///
277+
/// # Resource Usage
278+
///
279+
/// As this method fetches the git repository, loose objects or small packs may be created. Over time,
280+
/// these will accumulate and either slow down subsequent operations, or cause them to fail due to exhaustion
281+
/// of the maximum number of open file handles as configured with `ulimit`.
282+
///
283+
/// Thus it is advised for the caller to run `git gc` occasionally based on their own requirements and usage patterns.
284+
pub fn fetch_changes_with_options2(
285+
&self,
286+
progress: impl git::Progress,
287+
should_interrupt: &AtomicBool,
288+
) -> Result<Vec<Change>, Error> {
289+
let (changes, to) = self.peek_changes_with_options2(progress, should_interrupt)?;
290+
self.set_last_seen_reference(to)?;
291+
Ok(changes)
292+
}
293+
271294
/// Set the last seen reference to the given Oid. It will be created if it does not yet exists.
272295
pub fn set_last_seen_reference(&self, to: git::hash::ObjectId) -> Result<(), Error> {
273296
let repo = self.repository();

0 commit comments

Comments
 (0)