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

Method new

atomic-cli/tests/it/git_snapshot_lifecycle_regression.rs:63–134  ·  view source on GitHub ↗
(rolling: bool, full: bool)

Source from the content-addressed store, hash-verified

61 }
62
63 fn new(rolling: bool, full: bool) -> Self {
64 let fixture = Self {
65 root: TempDir::new().unwrap(),
66 home: TempDir::new().unwrap(),
67 };
68 fixture.git(&["init", "-q", "-b", "main"]);
69 fs::write(fixture.root.path().join("tracked.txt"), b"first\nsecond\n").unwrap();
70 if full {
71 fs::create_dir(fixture.root.path().join("dir")).unwrap();
72 fs::write(fixture.root.path().join("dir/café.txt"), b"cafe\n").unwrap();
73 fs::write(fixture.root.path().join("literal%20path.txt"), b"percent\n").unwrap();
74 fs::write(
75 fixture.root.path().join(".gitattributes"),
76 b"*.txt text eol=lf\n",
77 )
78 .unwrap();
79 fs::write(
80 fixture.root.path().join("run.sh"),
81 b"#!/bin/sh\necho fixture\n",
82 )
83 .unwrap();
84 fs::set_permissions(
85 fixture.root.path().join("run.sh"),
86 fs::Permissions::from_mode(0o755),
87 )
88 .unwrap();
89 symlink("tracked.txt", fixture.root.path().join("tracked-link")).unwrap();
90 }
91 fixture.git(&["add", "-A"]);
92 fixture.git(&["commit", "-qm", "seed"]);
93 if full {
94 fs::write(
95 fixture.root.path().join("tracked.txt"),
96 b"first\nsecond commit\n",
97 )
98 .unwrap();
99 fixture.git(&["add", "-A"]);
100 fixture.git(&["commit", "-qm", "text edit"]);
101 fixture.git(&["commit", "--allow-empty", "-qm", "empty"]);
102 }
103 let mut import = vec!["git", "import", "--no-vault"];
104 if !rolling {
105 import.push("--no-stream");
106 }
107 fixture.atomic(&import);
108 let key = fixture.home.path().join("binding.key");
109 fs::write(&key, "ab".repeat(32)).unwrap();
110 fixture.atomic(&[
111 "git",
112 "shim",
113 "enable",
114 "--no-refspecs",
115 "--binding-key-file",
116 key.to_str().unwrap(),
117 ]);
118 fixture.atomic(&["git", "shim", "reconcile"]);
119 fs::write(
120 fixture.root.path().join("tracked.txt"),

Callers

nothing calls this directly

Calls 7

set_permissionsFunction · 0.85
writeFunction · 0.70
unwrapMethod · 0.45
gitMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45
atomicMethod · 0.45

Tested by

no test coverage detected