diff --git a/git-odb/src/pack/data/encode/write.rs b/git-odb/src/pack/data/encode/write.rs index 12895ed29ea..c936a80d6a9 100644 --- a/git-odb/src/pack/data/encode/write.rs +++ b/git-odb/src/pack/data/encode/write.rs @@ -85,7 +85,13 @@ where written += std::io::copy(&mut &*entry.compressed_data, &mut self.output)? as u64; } } - None => todo!("write footer and set is_done = true"), + None => { + let digest = self.output.hash.clone().digest(); + self.output.write_all(&digest[..])?; + written += digest.len() as u64; + self.output.flush()?; + self.is_done = true; + } }; Ok(written) } diff --git a/git-odb/tests/odb/pack/data/encode.rs b/git-odb/tests/odb/pack/data/encode.rs index 679799b3ac7..88f3c605b03 100644 --- a/git-odb/tests/odb/pack/data/encode.rs +++ b/git-odb/tests/odb/pack/data/encode.rs @@ -18,7 +18,6 @@ mod entries { } #[test] - #[should_panic] fn all_input_objects() { (|| -> crate::Result { let db = db(DbKind::AbunchOfRandomObjects)?; @@ -48,7 +47,8 @@ mod entries { pack::data::Version::V2, git_hash::Kind::Sha1, ); - let n = pack_writer.next().expect("one entries bundle was written")?; + let mut n = pack_writer.next().expect("one entries bundle was written")?; + n += pack_writer.next().expect("the trailer was written")?; assert!( pack_writer.next().is_none(), "there is nothing more to iterate this time" @@ -63,6 +63,7 @@ mod entries { pack_file.metadata()?.len(), "it reports the correct amount of written bytes" ); + // TODO: verify the new pack Ok(()) })()