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

Method new

atomic-cli/tests/it/bridge_agent_workflow_regression_test.rs:17–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16impl Fixture {
17 fn new() -> Self {
18 let dir = tempfile::tempdir().unwrap();
19 let root = dir.path();
20 let git = git2::Repository::init(root).unwrap();
21 git.set_head("refs/heads/main").unwrap();
22 let mut config = git.config().unwrap();
23 config.set_str("user.name", "Bridge Test").unwrap();
24 config
25 .set_str("user.email", "bridge@example.invalid")
26 .unwrap();
27 config.set_str("core.hooksPath", ".git/hooks").unwrap();
28 let sig = git2::Signature::now("Bridge Test", "bridge@example.invalid").unwrap();
29 fs::write(root.join("tracked.txt"), b"base\n").unwrap();
30 let mut index = git.index().unwrap();
31 index.add_path(Path::new("tracked.txt")).unwrap();
32 index.write().unwrap();
33 let tree = git.find_tree(index.write_tree().unwrap()).unwrap();
34 let base = git
35 .commit(Some("HEAD"), &sig, &sig, "base", &tree, &[])
36 .unwrap();
37 drop(tree);
38 fs::write(root.join("tracked.txt"), b"feature edit\n").unwrap();
39 index.add_path(Path::new("tracked.txt")).unwrap();
40 index.write().unwrap();
41 let tree = git.find_tree(index.write_tree().unwrap()).unwrap();
42 let feature = git
43 .commit(
44 Some("refs/heads/feature"),
45 &sig,
46 &sig,
47 "feature",
48 &tree,
49 &[&git.find_commit(base).unwrap()],
50 )
51 .unwrap();
52 git.checkout_head(Some(git2::build::CheckoutBuilder::new().force()))
53 .unwrap();
54 drop(tree);
55 drop(index);
56 drop(config);
57 drop(git);
58 let f = Self { dir, feature };
59 f.atomic(&["git", "import", "--no-vault"]);
60 let key = root_key(f.root());
61 f.atomic(&[
62 "git",
63 "shim",
64 "enable",
65 "--no-refspecs",
66 "--binding-key-file",
67 key.to_str().unwrap(),
68 ]);
69 f.atomic(&["git", "shim", "reconcile"]);
70 f
71 }
72 fn root(&self) -> &Path {
73 self.dir.path()
74 }

Callers

nothing calls this directly

Calls 12

root_keyFunction · 0.85
forceMethod · 0.80
initFunction · 0.70
writeFunction · 0.70
unwrapMethod · 0.45
pathMethod · 0.45
indexMethod · 0.45
add_pathMethod · 0.45
writeMethod · 0.45
commitMethod · 0.45
atomicMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected