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

Function fixture

atomic-cli/src/commands/git/stream.rs:1601–1683  ·  view source on GitHub ↗
(count: usize)

Source from the content-addressed store, hash-verified

1599 builder.write().unwrap()
1600 }
1601 fn fixture(count: usize) -> (tempfile::TempDir, GitRepository, Oid, Files) {
1602 let temp = tempfile::tempdir().unwrap();
1603 let git = GitRepository::init_bare(temp.path()).unwrap();
1604 let mut files = Files::new();
1605 let mut previous = None;
1606 for index in 0..count {
1607 let put = |files: &mut Files, path: &str, bytes: &[u8], mode| {
1608 files.insert(path.into(), (bytes.to_vec(), mode));
1609 };
1610 match index % 16 {
1611 0 => {
1612 put(&mut files, "hot.txt", b"alpha\nbeta\nlast\n", 0o100644);
1613 put(&mut files, "stable.txt", b"stable\n", 0o100644);
1614 }
1615 1 => {
1616 put(&mut files, "hot.txt", b"alpha\nchanged\nlast\n", 0o100644);
1617 }
1618 2 => {
1619 put(&mut files, "nested/deep/empty", b"", 0o100644);
1620 }
1621 3 => {
1622 put(&mut files, "blob.bin", &[0, 1, 2, 255], 0o100644);
1623 }
1624 4 => {
1625 files.get_mut("hot.txt").unwrap().1 = 0o100755;
1626 }
1627 5 => {
1628 let file = files.remove("hot.txt").unwrap();
1629 files.insert("moved.txt".into(), file);
1630 }
1631 6 => {
1632 put(&mut files, "moved.txt", b"alpha\nlast\n", 0o100755);
1633 }
1634 7 => {
1635 files.remove("nested/deep/empty").unwrap();
1636 }
1637 8 => {
1638 put(&mut files, "nested/deep/recreated", b"again\n", 0o100644);
1639 }
1640 9 => {
1641 put(&mut files, "blob.bin", &[0, 9, 8, 7], 0o100644);
1642 }
1643 10 => {
1644 put(&mut files, "moved.txt", b"", 0o100755);
1645 }
1646 11 => {
1647 files.get_mut("moved.txt").unwrap().1 = 0o100644;
1648 }
1649 12 => {
1650 files.remove("blob.bin").unwrap();
1651 }
1652 13 => {
1653 files.remove("moved.txt").unwrap();
1654 put(&mut files, "hot.txt", b"alpha\nrestored\nlast\n", 0o100644);
1655 }
1656 14 => {
1657 files.remove("nested/deep/recreated").unwrap();
1658 }

Calls 9

get_mutMethod · 0.80
treeFunction · 0.70
removeMethod · 0.65
putFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
insertMethod · 0.45
commitMethod · 0.45
iterMethod · 0.45