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

Function edit

atomic-repository/tests/it/whole_file_diff_test.rs:23–38  ·  view source on GitHub ↗

Record `before`, then `after`, and return the second change.

(before: &[u8], after: &[u8])

Source from the content-addressed store, hash-verified

21
22/// Record `before`, then `after`, and return the second change.
23fn edit(before: &[u8], after: &[u8]) -> (TempDir, Repository, Hash, Change) {
24 let dir = TempDir::new().unwrap();
25 let repo = Repository::init(dir.path()).unwrap();
26 std::fs::write(dir.path().join("file.txt"), before).unwrap();
27 repo.add(
28 repo.require_working_copy_id().unwrap(),
29 "file.txt",
30 Default::default(),
31 )
32 .unwrap();
33 record(&repo);
34 std::fs::write(dir.path().join("file.txt"), after).unwrap();
35 let hash = record(&repo);
36 let change = repo.change_store().load_change(&hash).unwrap();
37 (dir, repo, hash, change)
38}
39
40/// An edit that must be stored as a whole-file rewrite.
41fn replacement(before: &[u8], after: &[u8]) -> (TempDir, Repository, Hash, Change) {

Calls 9

writeFunction · 0.70
recordFunction · 0.70
initFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
addMethod · 0.45
load_changeMethod · 0.45
change_storeMethod · 0.45

Tested by

no test coverage detected