| 780 | use crate::commands::git::checkpoint::{self, VerifiedCheckpointInput}; |
| 781 | |
| 782 | fn commit_file(repository: &GitRepository, root: &Path, content: &[u8], message: &str) -> Oid { |
| 783 | fs::write(root.join("tracked.txt"), content).unwrap(); |
| 784 | let mut index = repository.index().unwrap(); |
| 785 | index.add_path(Path::new("tracked.txt")).unwrap(); |
| 786 | index.write().unwrap(); |
| 787 | let tree_oid = index.write_tree().unwrap(); |
| 788 | let tree = repository.find_tree(tree_oid).unwrap(); |
| 789 | let signature = Signature::now("Atomic Test", "test@atomic.invalid").unwrap(); |
| 790 | let parents = repository |
| 791 | .head() |
| 792 | .ok() |
| 793 | .and_then(|head| head.target()) |
| 794 | .map(|oid| repository.find_commit(oid).unwrap()); |
| 795 | match parents.as_ref() { |
| 796 | Some(parent) => repository |
| 797 | .commit( |
| 798 | Some("HEAD"), |
| 799 | &signature, |
| 800 | &signature, |
| 801 | message, |
| 802 | &tree, |
| 803 | &[parent], |
| 804 | ) |
| 805 | .unwrap(), |
| 806 | None => repository |
| 807 | .commit(Some("HEAD"), &signature, &signature, message, &tree, &[]) |
| 808 | .unwrap(), |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | fn initialized_colocated_repository(root: &Path) -> (GitRepository, Oid) { |
| 813 | atomic_repository::Repository::init(root).unwrap(); |