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

Function init_git_with_commit

atomic-cli/src/commands/git/shim.rs:3464–3479  ·  view source on GitHub ↗
(root: &Path, branch: &str)

Source from the content-addressed store, hash-verified

3462 }
3463
3464 fn init_git_with_commit(root: &Path, branch: &str) {
3465 let repository = GitRepository::init(root).unwrap();
3466 repository
3467 .set_head(&format!("refs/heads/{branch}"))
3468 .unwrap();
3469 fs::write(root.join("tracked.txt"), b"tracked\n").unwrap();
3470 let mut index = repository.index().unwrap();
3471 index.add_path(Path::new("tracked.txt")).unwrap();
3472 index.write().unwrap();
3473 let tree_oid = index.write_tree().unwrap();
3474 let tree = repository.find_tree(tree_oid).unwrap();
3475 let signature = Signature::now("Atomic Test", "atomic@example.com").unwrap();
3476 repository
3477 .commit(Some("HEAD"), &signature, &signature, "initial", &tree, &[])
3478 .unwrap();
3479 }
3480
3481 #[test]
3482 fn enable_records_opt_in_and_disable_rolls_back() {

Calls 7

initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
indexMethod · 0.45
add_pathMethod · 0.45
writeMethod · 0.45
commitMethod · 0.45