()
| 21 | } |
| 22 | |
| 23 | async fn fixture() -> (tempfile::TempDir, LocalService, pb::RepositoryRef) { |
| 24 | let dir = tempfile::tempdir().unwrap(); |
| 25 | let mut repo = Repository::init(dir.path()).unwrap(); |
| 26 | let wc = repo.require_working_copy_id().unwrap(); |
| 27 | std::fs::create_dir_all(dir.path().join("src")).unwrap(); |
| 28 | std::fs::write( |
| 29 | dir.path().join("src/lib.rs"), |
| 30 | "pub fn target() {}\npub fn caller() { target(); }\n// inherited_marker\n", |
| 31 | ) |
| 32 | .unwrap(); |
| 33 | repo.add(wc, "src/lib.rs", TrackingOptions::default()) |
| 34 | .unwrap(); |
| 35 | record(&repo, "inherited history"); |
| 36 | repo.kg_enrich_from_vcs(wc).unwrap(); |
| 37 | repo.create_draft_view("feature", "dev").unwrap(); |
| 38 | repo.switch_view(wc, "feature").unwrap(); |
| 39 | std::fs::write( |
| 40 | dir.path().join("src/lib.rs"), |
| 41 | "pub fn target(secret: SiblingSecret) {}\npub fn caller() {}\n// inherited_marker\n", |
| 42 | ) |
| 43 | .unwrap(); |
| 44 | std::fs::write( |
| 45 | dir.path().join("src/hidden.rs"), |
| 46 | "pub fn sibling_only() { target(); }\n// sibling_marker\n", |
| 47 | ) |
| 48 | .unwrap(); |
| 49 | repo.add(wc, "src/hidden.rs", TrackingOptions::default()) |
| 50 | .unwrap(); |
| 51 | record(&repo, "sibling history"); |
| 52 | repo.kg_enrich_from_vcs(wc).unwrap(); |
| 53 | atomic_repository::build_content_index(dir.path()).unwrap(); |
| 54 | repo.switch_view(wc, "dev").unwrap(); |
| 55 | drop(repo); |
| 56 | // Neither this derived marker nor unrecorded disk bytes are authoritative. |
| 57 | std::fs::write(dir.path().join(".atomic/current_view"), "feature").unwrap(); |
| 58 | std::fs::write(dir.path().join("src/lib.rs"), "pub fn disk_only() {}\n").unwrap(); |
| 59 | let service = LocalService::new(); |
| 60 | let bytes = service |
| 61 | .call( |
| 62 | "/atomic.DaemonService/ResolveRepository", |
| 63 | &pb::ResolveRepositoryRequest { |
| 64 | path: dir.path().display().to_string(), |
| 65 | } |
| 66 | .encode_to_vec(), |
| 67 | ) |
| 68 | .await |
| 69 | .unwrap(); |
| 70 | let reference = pb::ResolveRepositoryResponse::decode(bytes.as_slice()) |
| 71 | .unwrap() |
| 72 | .repository |
| 73 | .unwrap(); |
| 74 | (dir, service, reference) |
| 75 | } |
| 76 | |
| 77 | fn view(name: &str) -> pb::ViewRef { |
| 78 | pb::ViewRef { |
no test coverage detected