diff options
| author | seth <[email protected]> | 2024-10-12 09:36:52 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-10-12 09:36:52 -0400 |
| commit | 35f9d5634450ed8fd6428b7d8b7f5c2b06d01a21 (patch) | |
| tree | d13c950f7739a1b107b733bc61035b05d518e5f6 /crates/git-tracker/src | |
| parent | 7ff741ab80f2cc6aec658be633ca6a5a5a0ff5cc (diff) | |
git-tracker: don't keep re-opening repository
Diffstat (limited to 'crates/git-tracker/src')
| -rw-r--r-- | crates/git-tracker/src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/git-tracker/src/lib.rs b/crates/git-tracker/src/lib.rs index e2feb32..d7f2d9e 100644 --- a/crates/git-tracker/src/lib.rs +++ b/crates/git-tracker/src/lib.rs @@ -159,12 +159,15 @@ impl TrackedRepository { /// /// Will return [`Err`] if the repository cannot be opened, HEAD cannot be resolved, or the /// relation between commits cannot be resolved - pub fn ref_contains_object(&self, reference: &Reference, commit: Oid) -> Result<bool, Error> { + pub fn ref_contains_object( + repository: &Repository, + reference: &Reference, + commit: Oid, + ) -> Result<bool, Error> { trace!( "Checking for commit {commit} in {}", reference.name().unwrap_or("<branch>") ); - let repository = self.open()?; let head = reference.peel_to_commit()?; // NOTE: we have to check this as `Repository::graph_descendant_of()` (like the name says) @@ -201,7 +204,8 @@ impl TrackedRepository { BranchType::Remote, )?; - let has_commit = self.ref_contains_object(&branch.into_reference(), commit)?; + let has_commit = + Self::ref_contains_object(&repository, &branch.into_reference(), commit)?; results.push((branch_name, has_commit)); } |
