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

Method new

atomic-repository/src/repository/tests/resurrection_tests.rs:144–182  ·  view source on GitHub ↗
(directory: &Path)

Source from the content-addressed store, hash-verified

142
143impl Publisher {
144 fn new(directory: &Path) -> Self {
145 let repo = Repository::init(directory).unwrap();
146
147 fs::create_dir_all(directory.join("nested")).unwrap();
148 fs::write(directory.join("nested/alpha.txt"), b"alpha body\n").unwrap();
149 record_all(&repo, "first");
150 fs::write(directory.join("nested/alpha.txt"), b"alpha body v2\n").unwrap();
151 record_all(&repo, "second");
152 fs::write(directory.join("empty.txt"), b"").unwrap();
153 record_all(&repo, "third");
154
155 let view = repo.current_view().to_string();
156 let identity = repo.view_identity(&view).unwrap();
157 let ordered: Vec<Hash> = repo
158 .effective_history(Some(&view))
159 .unwrap()
160 .iter()
161 .map(|entry| entry.hash)
162 .collect();
163
164 let policy = ConversionPolicy::new(GitHashAlgorithm::Sha1);
165 let project = repo.project_tree(&view, &policy).unwrap();
166 let git = git2::Repository::init_opts(
167 directory.join("bridge.git"),
168 git2::RepositoryInitOptions::new().bare(true),
169 )
170 .unwrap();
171 let (commit, raw_commit) = bind_projection_to_commit(&git, &project);
172 Self {
173 repo,
174 ordered,
175 set_id: identity.set_id,
176 merkle: identity.merkle,
177 commit_hex: commit.to_string(),
178 tree_hex: hex_oid(&project.git.root),
179 raw_commit,
180 view,
181 }
182 }
183
184 fn binding(&self, seed: u8) -> GitStateBinding {
185 signed_binding(

Callers

nothing calls this directly

Calls 13

view_identityMethod · 0.80
effective_historyMethod · 0.80
project_treeMethod · 0.80
bareMethod · 0.80
record_allFunction · 0.70
hex_oidFunction · 0.70
initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
current_viewMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected