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

Function init_fixture

atomic-cli/tests/it/git_push_cb4b_test.rs:28–52  ·  view source on GitHub ↗
(root: &Path, home: &Path)

Source from the content-addressed store, hash-verified

26}
27
28fn init_fixture(root: &Path, home: &Path) {
29 let git = GitRepository::init(root).expect("init Git");
30 git.set_head("refs/heads/main").expect("set main HEAD");
31 fs::write(root.join("tracked.txt"), b"git-only\n").expect("write Git file");
32 let mut index = git.index().expect("open index");
33 index
34 .add_path(Path::new("tracked.txt"))
35 .expect("stage Git file");
36 index.write().expect("write index");
37 let tree_oid = index.write_tree().expect("write tree");
38 let tree = git.find_tree(tree_oid).expect("find tree");
39 let signature = Signature::now("Atomic Test", "atomic@example.com").expect("signature");
40 git.commit(Some("HEAD"), &signature, &signature, "initial", &tree, &[])
41 .expect("commit Git file");
42 drop(tree);
43 drop(git);
44
45 let output = atomic(root, home, &["init", "--view", "main"]);
46 assert!(
47 output.status.success(),
48 "atomic init failed:\nstdout:\n{}\nstderr:\n{}",
49 String::from_utf8_lossy(&output.stdout),
50 String::from_utf8_lossy(&output.stderr)
51 );
52}
53
54#[derive(Debug, Eq, PartialEq)]
55enum SnapshotValue {

Calls 7

initFunction · 0.70
writeFunction · 0.70
atomicFunction · 0.70
indexMethod · 0.45
add_pathMethod · 0.45
writeMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected