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

Function corpus

atomic-cli/tests/it/git_import_cb9c_test.rs:274–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272}
273
274fn corpus() -> Corpus {
275 let root = tempfile::tempdir().unwrap().keep();
276 let home = tempfile::tempdir().unwrap().keep();
277 git(&root, &["init", "-q", "-b", "main"]);
278 git(&root, &["config", "protocol.file.allow", "always"]);
279
280 // Base tree.
281 fs::create_dir_all(root.join("docs")).unwrap();
282 fs::create_dir_all(root.join("src")).unwrap();
283 fs::write(root.join("docs/placeholder"), b"gone\n").unwrap();
284 fs::write(
285 root.join("src/main.rs"),
286 b"fn main() {\n println!(\"hello\");\n}\n",
287 )
288 .unwrap();
289 let _base = git_commit(&root, "base");
290
291 // Pure rename: docs/placeholder → docs/intro.md, byte-identical.
292 fs::remove_file(root.join("docs/placeholder")).unwrap();
293 fs::write(root.join("docs/intro.md"), b"gone\n").unwrap();
294 let pure_rename = git_commit(&root, "pure rename");
295
296 // Rename + small edit: src/main.rs → src/entry.rs. The edit is small
297 // enough that Git's similarity detection resolves the rename, so the
298 // import records similarity-class move evidence.
299 fs::remove_file(root.join("src/main.rs")).unwrap();
300 fs::write(
301 root.join("src/entry.rs"),
302 b"fn main() {\n println!(\"hello\");\n println!(\"edited\");\n}\n",
303 )
304 .unwrap();
305 let rename_edit = git_commit(&root, "rename edit");
306
307 // Attribute-only: chmod +x on a tracked file (no byte change).
308 #[cfg(unix)]
309 let mut perms = fs::metadata(root.join("src/entry.rs"))
310 .unwrap()
311 .permissions();
312 #[cfg(unix)]
313 {
314 use std::os::unix::fs::PermissionsExt;
315 perms.set_mode(0o755);
316 fs::set_permissions(root.join("src/entry.rs"), perms).unwrap();
317 }
318 let chmod_on = git_commit(&root, "chmod executable");
319
320 // Symlinks: relative dangling and absolute targets.
321 #[cfg(unix)]
322 {
323 std::os::unix::fs::symlink("docs/missing.txt", root.join("dangling.lnk")).unwrap();
324 std::os::unix::fs::symlink("/absolute/target", root.join("abs.lnk")).unwrap();
325 let _symlinks = git_commit(&root, "add symlinks");
326 }
327
328 // symlink → regular file; regular → symlink.
329 fs::remove_file(root.join("abs.lnk")).unwrap();
330 fs::write(root.join("abs.lnk"), b"now a regular file\n").unwrap();
331 fs::remove_file(root.join("src/entry.rs")).unwrap();

Calls 8

set_permissionsFunction · 0.85
set_modeMethod · 0.80
gitFunction · 0.70
writeFunction · 0.70
git_commitFunction · 0.70
unwrapMethod · 0.45
permissionsMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected