mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Fix implementation of GitDatabase::contains
(#4698)
## Summary `GitDatabase::contains` previously only parsed the commit to see if it was a valid hash and didn't verify if the commit existed in the object database. This led to the database never being updated. Resolves https://github.com/astral-sh/uv/issues/4378. ## Test Plan Added a test that fails without this change.
This commit is contained in:
parent
5715def24b
commit
58499439d3
2 changed files with 50 additions and 3 deletions
|
@ -175,7 +175,7 @@ impl GitRepository {
|
|||
})
|
||||
}
|
||||
|
||||
/// Fetches the object ID of the given `refname`.
|
||||
/// Parses the object ID of the given `refname`.
|
||||
fn rev_parse(&self, refname: &str) -> Result<GitOid> {
|
||||
let result = ProcessBuilder::new("git")
|
||||
.arg("rev-parse")
|
||||
|
@ -295,9 +295,9 @@ impl GitDatabase {
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
/// Checks if the database contains the object of this `oid`.
|
||||
/// Checks if `oid` resolves to a commit in this database.
|
||||
pub(crate) fn contains(&self, oid: GitOid) -> bool {
|
||||
self.repo.rev_parse(oid.as_str()).is_ok()
|
||||
self.repo.rev_parse(&format!("{oid}^0")).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue