| 3462 | } |
| 3463 | |
| 3464 | fn init_git_with_commit(root: &Path, branch: &str) { |
| 3465 | let repository = GitRepository::init(root).unwrap(); |
| 3466 | repository |
| 3467 | .set_head(&format!("refs/heads/{branch}")) |
| 3468 | .unwrap(); |
| 3469 | fs::write(root.join("tracked.txt"), b"tracked\n").unwrap(); |
| 3470 | let mut index = repository.index().unwrap(); |
| 3471 | index.add_path(Path::new("tracked.txt")).unwrap(); |
| 3472 | index.write().unwrap(); |
| 3473 | let tree_oid = index.write_tree().unwrap(); |
| 3474 | let tree = repository.find_tree(tree_oid).unwrap(); |
| 3475 | let signature = Signature::now("Atomic Test", "atomic@example.com").unwrap(); |
| 3476 | repository |
| 3477 | .commit(Some("HEAD"), &signature, &signature, "initial", &tree, &[]) |
| 3478 | .unwrap(); |
| 3479 | } |
| 3480 | |
| 3481 | #[test] |
| 3482 | fn enable_records_opt_in_and_disable_rolls_back() { |