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

Function init_git_commit

atomic-cli/src/commands/git/watch.rs:695–720  ·  view source on GitHub ↗
(root: &Path, message: &str)

Source from the content-addressed store, hash-verified

693 }
694
695 fn init_git_commit(root: &Path, message: &str) {
696 use git2::Signature;
697 let repository = git2::Repository::init(root).unwrap();
698 fs::write(root.join("tracked.txt"), message.as_bytes()).unwrap();
699 let mut index = repository.index().unwrap();
700 index.add_path(Path::new("tracked.txt")).unwrap();
701 index.write().unwrap();
702 let tree_oid = index.write_tree().unwrap();
703 let tree = repository.find_tree(tree_oid).unwrap();
704 let signature = Signature::now("CB-13D Tests", "cb13d@example.com").unwrap();
705 let parent = repository
706 .head()
707 .ok()
708 .and_then(|head| head.peel_to_commit().ok());
709 let parents: Vec<&git2::Commit> = parent.iter().collect();
710 repository
711 .commit(
712 Some("HEAD"),
713 &signature,
714 &signature,
715 message,
716 &tree,
717 &parents,
718 )
719 .unwrap();
720 }
721
722 #[test]
723 fn hint_observes_truth_through_git_apis() {

Calls 12

initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
as_bytesMethod · 0.45
indexMethod · 0.45
add_pathMethod · 0.45
writeMethod · 0.45
okMethod · 0.45
headMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
commitMethod · 0.45