╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ patch.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1263 try target.removeBranch(io, .{ .name = "master" }); 1264 pch.refreshMergeability(repo_opts, io, allocator, target, null); 1265 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, patch)); 1266 try expectMergeabilityShortBytes(try target.core.latestMoment(), id); 1267 try target.addBranch(io, .{ .name = "master" }); 1268 { 1269 var restored = try target.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "master" } } }); 1270 defer restored.deinit(); 1271 } 1272 pch.refreshMergeability(repo_opts, io, allocator, target, null); 1273 try std.testing.expectEqualDeep(clean, try readMergeability(target, io, allocator, id, patch)); 1274 1275 // a missing fork disables merging without changing the accepted events 1276 const draft_path = try fork.forkPath(allocator, repos_dir, &std.fmt.bytesToHex(id.*, .lower)); 1277 defer allocator.free(draft_path); 1278 const away_path = try std.fmt.allocPrint(allocator, "{s}.away", .{draft_path}); 1279 defer allocator.free(away_path); 1280 { 1281 try std.Io.Dir.renameAbsolute(draft_path, away_path, io); 1282 defer std.Io.Dir.renameAbsolute(away_path, draft_path, io) catch {}; 1283 { 1284 const log_level = std.testing.log_level; 1285 std.testing.log_level = .err; 1286 defer std.testing.log_level = log_level; 1287 try std.testing.expectError(error.PatchDataUnavailable, pch.merge(repo_opts, io, allocator, repos_dir, target, input)); 1288 } 1289 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, patch)); 1290 try std.testing.expectEqual(events_before, try target.readRef(io, evt.events_ref)); 1291 } 1292 pch.refreshMergeability(repo_opts, io, allocator, target, id.*); 1293 try std.testing.expectEqualDeep(clean, try readMergeability(target, io, allocator, id, patch)); 1294 1295 // a changed revision is unknown even if its target has not moved 1296 var changed = patch; 1297 changed.revision.?.id[0] = if (changed.revision.?.id[0] == 'a') 'b' else 'a'; 1298 try std.testing.expectEqualDeep(pch.Mergeability{}, try readMergeability(target, io, allocator, id, changed)); 1299 } 1300