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

Function fixture

atomic-cli/tests/it/git_import_tracked_vault_regression.rs:118–145  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

116/// Build a two-commit repository; `with_vault` controls whether the history
117/// tracks custom `.vault/` content, and return its root and isolated HOME.
118fn 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

Calls 7

tracked_vault_filesFunction · 0.85
extendMethod · 0.80
forceMethod · 0.80
initFunction · 0.70
commitFunction · 0.70
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected