| 693 | } |
| 694 | |
| 695 | fn init_git_commit(root: &Path, message: &str) { |
| 696 | use git2::Signature; |
| 697 | let repository = git2::Repository::init(root).unwrap(); |
| 698 | fs::write(root.join("tracked.txt"), message.as_bytes()).unwrap(); |
| 699 | let mut index = repository.index().unwrap(); |
| 700 | index.add_path(Path::new("tracked.txt")).unwrap(); |
| 701 | index.write().unwrap(); |
| 702 | let tree_oid = index.write_tree().unwrap(); |
| 703 | let tree = repository.find_tree(tree_oid).unwrap(); |
| 704 | let signature = Signature::now("CB-13D Tests", "cb13d@example.com").unwrap(); |
| 705 | let parent = repository |
| 706 | .head() |
| 707 | .ok() |
| 708 | .and_then(|head| head.peel_to_commit().ok()); |
| 709 | let parents: Vec<&git2::Commit> = parent.iter().collect(); |
| 710 | repository |
| 711 | .commit( |
| 712 | Some("HEAD"), |
| 713 | &signature, |
| 714 | &signature, |
| 715 | message, |
| 716 | &tree, |
| 717 | &parents, |
| 718 | ) |
| 719 | .unwrap(); |
| 720 | } |
| 721 | |
| 722 | #[test] |
| 723 | fn hint_observes_truth_through_git_apis() { |