| 29 | |
| 30 | #[cfg(unix)] |
| 31 | fn commit_git_paths(root: &Path, message: &str, paths: &[&str]) { |
| 32 | let git = git2::Repository::open(root).unwrap(); |
| 33 | let mut index = git.index().unwrap(); |
| 34 | index.clear().unwrap(); |
| 35 | for path in paths { |
| 36 | index.add_path(Path::new(path)).unwrap(); |
| 37 | } |
| 38 | index.write().unwrap(); |
| 39 | let tree = git.find_tree(index.write_tree().unwrap()).unwrap(); |
| 40 | let author = git2::Signature::now("Regression", "regression@example.test").unwrap(); |
| 41 | let parent = git.head().ok().and_then(|head| head.peel_to_commit().ok()); |
| 42 | let parents: Vec<_> = parent.iter().collect(); |
| 43 | git.commit(Some("HEAD"), &author, &author, message, &tree, &parents) |
| 44 | .unwrap(); |
| 45 | } |
| 46 | |
| 47 | // Git shim integration currently requires Unix raw-byte path support. |
| 48 | #[cfg(unix)] |