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)
| 313 | /// Install a real, aligned Git baseline without invoking the user's hooks. |
| 314 | /// A subsequent edit makes workspace reconciliation capture a WIP snapshot. |
| 315 | fn 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 | |
| 359 | fn persistent_files(root: &std::path::Path) -> std::collections::BTreeMap<String, Vec<u8>> { |
| 360 | fn collect( |
no test coverage detected