(git: &git2::Repository, root: &Path, name: &str, content: &str)
| 1238 | } |
| 1239 | |
| 1240 | fn commit_file(git: &git2::Repository, root: &Path, name: &str, content: &str) -> String { |
| 1241 | std::fs::write(root.join(name), content).unwrap(); |
| 1242 | let mut index = git.index().unwrap(); |
| 1243 | index.add_path(Path::new(name)).unwrap(); |
| 1244 | index.write().unwrap(); |
| 1245 | let tree_id = index.write_tree().unwrap(); |
| 1246 | let tree = git.find_tree(tree_id).unwrap(); |
| 1247 | let signature = git2::Signature::now("Turn Test", "turn@test.invalid").unwrap(); |
| 1248 | let parent = git.head().ok().and_then(|head| head.peel_to_commit().ok()); |
| 1249 | let parents: Vec<&git2::Commit> = parent.iter().collect(); |
| 1250 | git.commit( |
| 1251 | Some("HEAD"), |
| 1252 | &signature, |
| 1253 | &signature, |
| 1254 | "test commit", |
| 1255 | &tree, |
| 1256 | &parents, |
| 1257 | ) |
| 1258 | .unwrap() |
| 1259 | .to_string() |
| 1260 | } |
| 1261 | |
| 1262 | fn make_options<'a>( |
| 1263 | session: &'a AgentSession, |
no test coverage detected