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

Function added_commit

atomic-cli/src/commands/git/parallel.rs:9725–9779  ·  view source on GitHub ↗
(path: &str, content: &[u8])

Source from the content-addressed store, hash-verified

9723 use super::*;
9724
9725 fn added_commit(path: &str, content: &[u8]) -> ParsedCommit {
9726 let policy = ConversionPolicy::new(GitHashAlgorithm::Sha1);
9727 let entry = RepositoryEntry::new(
9728 RepoPath::from_bytes(path.as_bytes()).unwrap(),
9729 content.to_vec(),
9730 0o644,
9731 atomic_core::change::InodeKind::Regular,
9732 None,
9733 ManifestDisposition::Included,
9734 )
9735 .unwrap();
9736 let manifest =
9737 RepositoryManifest::new(SetId::ZERO, policy.root().content_key, vec![entry]).unwrap();
9738 let project = ProjectTree::from_manifest(manifest, &policy).unwrap();
9739 let tree_oid = Oid::from_bytes(project.git.root.as_bytes()).unwrap();
9740 ParsedCommit {
9741 git_sha: "0123456789abcdef".to_string(),
9742 short_sha: "01234567".to_string(),
9743 metadata: CommitMetadata {
9744 author_name: "Test".to_string(),
9745 author_email: Some("test@example.com".to_string()),
9746 author_name_raw: b"Test".to_vec(),
9747 author_email_raw: Some(b"test@example.com".to_vec()),
9748 timestamp: Utc::now(),
9749 message: format!("add {path}"),
9750 description: None,
9751 author_time: 1_700_000_000,
9752 author_time_offset_seconds: 0,
9753 committer_name: "Test".to_string(),
9754 committer_email: Some("test@example.com".to_string()),
9755 committer_name_raw: b"Test".to_vec(),
9756 committer_email_raw: Some(b"test@example.com".to_vec()),
9757 committer_time: 1_700_000_000,
9758 committer_time_offset_seconds: 0,
9759 },
9760 files: vec![ParsedFile {
9761 path: path.to_string(),
9762 operation: FileOperation::Added,
9763 new_content: Some(content.to_vec()),
9764 old_content: None,
9765 diff_lines: None,
9766 old_path: None,
9767 new_mode: Some(0o100644),
9768 }],
9769 parent_index: None,
9770 parent_oids: Vec::new(),
9771 committer_time: 1_700_000_000,
9772 is_merge: false,
9773 is_empty: false,
9774 push_trailer: None,
9775 tree_oid,
9776 parent_tree_oid: None,
9777 raw_object: Vec::new(),
9778 }
9779 }
9780
9781 #[test]
9782 fn pure_rename_diff_evidence_requires_a_complete_git_diff() {

Calls 3

unwrapMethod · 0.45
as_bytesMethod · 0.45
rootMethod · 0.45