MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / commit_file

Function commit_file

atomic-agent/src/record/tests.rs:1240–1260  ·  view source on GitHub ↗
(git: &git2::Repository, root: &Path, name: &str, content: &str)

Source from the content-addressed store, hash-verified

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,

Calls 10

writeFunction · 0.50
unwrapMethod · 0.45
indexMethod · 0.45
add_pathMethod · 0.45
writeMethod · 0.45
okMethod · 0.45
headMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected