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