Build a two-commit repository; `with_vault` controls whether the history tracks custom `.vault/` content, and return its root and isolated HOME.
(with_vault: bool)
| 116 | /// Build a two-commit repository; `with_vault` controls whether the history |
| 117 | /// tracks custom `.vault/` content, and return its root and isolated HOME. |
| 118 | fn fixture(with_vault: bool) -> (tempfile::TempDir, tempfile::TempDir) { |
| 119 | let root = tempfile::tempdir().unwrap(); |
| 120 | let home = tempfile::tempdir().unwrap(); |
| 121 | let git = GitRepository::init(root.path()).unwrap(); |
| 122 | let mut git_config = git.config().unwrap(); |
| 123 | git_config.set_str("user.name", "Vault Fixture").unwrap(); |
| 124 | git_config |
| 125 | .set_str("user.email", "vault@example.com") |
| 126 | .unwrap(); |
| 127 | drop(git_config); |
| 128 | |
| 129 | let mut first: Vec<(&str, &str)> = vec![("src/main.rs", "fn main() { println!(\"v1\"); }\n")]; |
| 130 | if with_vault { |
| 131 | first.extend(tracked_vault_files()); |
| 132 | } |
| 133 | let first_commit = commit(&git, &first, "c1: project + vault", None); |
| 134 | |
| 135 | let mut second: Vec<(&str, &str)> = vec![("src/main.rs", "fn main() { println!(\"v2\"); }\n")]; |
| 136 | if with_vault { |
| 137 | second.extend(tracked_vault_files()); |
| 138 | } |
| 139 | commit(&git, &second, "c2: bump main.rs", Some(first_commit)); |
| 140 | |
| 141 | git.set_head("refs/heads/main").unwrap(); |
| 142 | git.checkout_head(Some(git2::build::CheckoutBuilder::new().force())) |
| 143 | .unwrap(); |
| 144 | (root, home) |
| 145 | } |
| 146 | |
| 147 | /// Import must preserve the tracked vault byte-for-byte, keep `git status` |
| 148 | /// clean, hydrate the vault database with the user's content, and leave |
no test coverage detected