MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / record_with_deps

Function record_with_deps

atomic-repository/src/git_binding/pack.rs:632–658  ·  view source on GitHub ↗
(
        message: &str,
        deps: Vec<Hash>,
        unhashed: Option<serde_json::Value>,
    )

Source from the content-addressed store, hash-verified

630 use atomic_core::change::{Author, ChangeHeader};
631
632 fn record_with_deps(
633 message: &str,
634 deps: Vec<Hash>,
635 unhashed: Option<serde_json::Value>,
636 ) -> (ObjectRecord, Change) {
637 let header = ChangeHeader::builder()
638 .message(message)
639 .author(Author::new("Test", Some("test@example.com")))
640 .build();
641 let mut change = Change::new(
642 header,
643 Vec::new(),
644 format!("{message}\n").into_bytes(),
645 deps,
646 );
647 change.unhashed = unhashed;
648 let mut bytes = Vec::new();
649 change
650 .serialize(&mut std::io::Cursor::new(&mut bytes))
651 .expect("serialize");
652 // Pack records are addressed by blake3 of the exact file bytes (the
653 // CB-6A pack contract), not by the change identity hash.
654 (
655 ObjectRecord::new(ObjectFamily::Change, Hash::of(&bytes).to_hex(), bytes),
656 change,
657 )
658 }
659
660 fn plain_change(message: &str) -> (ObjectRecord, Change) {
661 record_with_deps(message, Vec::new(), None)

Calls 5

authorMethod · 0.80
buildMethod · 0.45
messageMethod · 0.45
serializeMethod · 0.45
to_hexMethod · 0.45