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

Function bridge_checkpoint

libatomic/tests/record_service_test.rs:315–357  ·  view source on GitHub ↗

Install a real, aligned Git baseline without invoking the user's hooks. A subsequent edit makes workspace reconciliation capture a WIP snapshot.

(root: &std::path::Path)

Source from the content-addressed store, hash-verified

313/// Install a real, aligned Git baseline without invoking the user's hooks.
314/// A subsequent edit makes workspace reconciliation capture a WIP snapshot.
315fn bridge_checkpoint(root: &std::path::Path) {
316 use atomic_core::types::Base32;
317 let git = |args: &[&str]| {
318 let output = std::process::Command::new("git")
319 .args(args)
320 .current_dir(root)
321 .env("GIT_CONFIG_NOSYSTEM", "1")
322 .env("GIT_AUTHOR_NAME", "Service Test")
323 .env("GIT_AUTHOR_EMAIL", "tests@atomic.dev")
324 .env("GIT_COMMITTER_NAME", "Service Test")
325 .env("GIT_COMMITTER_EMAIL", "tests@atomic.dev")
326 .output()
327 .unwrap();
328 assert!(
329 output.status.success(),
330 "git {args:?}: {}",
331 String::from_utf8_lossy(&output.stderr)
332 );
333 String::from_utf8(output.stdout).unwrap().trim().to_string()
334 };
335 git(&["init", "-b", "dev"]);
336 git(&["add", "README.md"]);
337 let tree = git(&["write-tree"]);
338 let head = git(&["commit-tree", &tree, "-m", "baseline"]);
339 git(&["update-ref", "refs/heads/dev", &head]);
340 let repo = Repository::open_readonly(root).unwrap();
341 let state = repo.get_view_info("dev").unwrap().state.to_base32();
342 let path = root.join(".atomic/bridge/workspace.json");
343 std::fs::create_dir_all(path.parent().unwrap()).unwrap();
344 std::fs::write(
345 path,
346 serde_json::to_vec(&serde_json::json!({
347 "version": 2,
348 "view": "dev",
349 "atomic_state": state,
350 "git_head_symref": "refs/heads/dev",
351 "git_head": head,
352 "git_tree": tree,
353 }))
354 .unwrap(),
355 )
356 .unwrap();
357}
358
359fn persistent_files(root: &std::path::Path) -> std::collections::BTreeMap<String, Vec<u8>> {
360 fn collect(

Calls 7

get_view_infoMethod · 0.80
parentMethod · 0.80
writeFunction · 0.70
gitFunction · 0.50
unwrapMethod · 0.45
outputMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected