Skip to content

Commit ea0d591

Browse files
committed
feat: add GIX_TEST_FIXTURE_HASH
- Create separate fixtures for non-SHA1 hashes - Update expected sizes in tests compiled with sha256 support - Explicitly track sha256 portion of expected sizes - Include sha1 in path for generated fixture - Add hash kind to path in snapshot - Error when GIX_TEST_FIXTURE_HASH is invalid - Add Graph::object_hash
1 parent 28fbeb8 commit ea0d591

32 files changed

Lines changed: 177 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-commitgraph/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ document-features = { version = "0.2.0", optional = true }
3333
[dev-dependencies]
3434
gix-testtools = { path = "../tests/tools" }
3535
gix-date = { path = "../gix-date" }
36+
gix-hash = { path = "../gix-hash", features = ["sha256"] }
3637

3738
[package.metadata.docs.rs]
3839
all-features = true

gix-commitgraph/src/access.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ impl Graph {
1111
r.file.commit_at(r.pos)
1212
}
1313

14+
/// The kind of hash used in this `Graph`.
15+
///
16+
/// Note that it is always conforming to the hash used in the owning repository.
17+
///
18+
/// # Panics
19+
///
20+
/// If the graph does not contain any `File`.
21+
pub fn object_hash(&self) -> gix_hash::Kind {
22+
self.files
23+
.first()
24+
.map(super::File::object_hash)
25+
.expect("graph to have at least one file")
26+
}
27+
1428
/// Returns the commit matching the given `id`.
1529
pub fn commit_by_id(&self, id: impl AsRef<gix_hash::oid>) -> Option<Commit<'_>> {
1630
let r = self.lookup_by_id(id.as_ref())?;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

gix-diff/src/tree/visit.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@ mod tests {
151151
#[test]
152152
fn size_of_change() {
153153
let actual = std::mem::size_of::<Change>();
154+
let sha1 = 48;
155+
let sha256_extra = 24;
156+
let ceiling = sha1 + sha256_extra;
154157
assert!(
155-
actual <= 48,
156-
"{actual} <= 48: this type shouldn't grow without us knowing"
158+
actual <= ceiling,
159+
"{actual} <= {ceiling}: this type shouldn't grow without us knowing"
157160
);
158161
}
159162
}

0 commit comments

Comments
 (0)