╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1173 fn seedPatches( 1174 io: std.Io, 1175 allocator: std.mem.Allocator, 1176 server_path: []const u8, 1177 admin_repo: *rp.Repo(.xit, evt.admin_repo_opts), 1178 target_repo: *rp.Repo(.xit, .{}), 1179 repo_id: *const [evt.event_id_size]u8, 1180 repo_user_id: *const [evt.event_id_size]u8, 1181 user_id: *const [evt.event_id_size]u8, 1182 random: std.Random, 1183 ) !void { 1184 const patch_data = [_]struct { 1185 title: []const u8, 1186 description: []const u8, 1187 labels: []const u8, 1188 status: ?evt.Patch.StatusKind, 1189 alpha_edit: ?ScatterEdit = null, 1190 // based behind master, so merging it makes a merge commit 1191 behind_master: bool = false, 1192 // a base file the patch removes 1193 removed_path: ?[]const u8 = null, 1194 }{ 1195 .{ 1196 .title = "Draft a faster dependency scanner", 1197 .description = "Rework dependency discovery so a **large workspace** can be scanned without repeatedly opening the same manifests.", 1198 .labels = "performance build", 1199 .status = null, 1200 }, 1201 .{ 1202 .title = "Remove the legacy configuration loader", 1203 .description = "Delete the compatibility loader now that the replacement format has shipped and the migration warning has been available for a *full release*.", 1204 .labels = "cleanup config", 1205 .status = .merged, 1206 .behind_master = true, 1207 }, 1208 .{ 1209 .title = "Cache parsed manifests between commands", 1210 .description = "Keep parsed manifests in the command `Context` so consecutive operations do not repeat identical filesystem and parsing work.", 1211 .labels = "performance cache", 1212 .status = .closed, 1213 }, 1214 .{ 1215 .title = "Add structured output to the inspect command", 1216 .description = "Add a stable JSON representation of `inspect` results for scripts and editor integrations.", 1217 .labels = "enhancement cli", 1218 .status = .open, 1219 .removed_path = "docs/dev/contribute.md", 1220 }, 1221 .{ 1222 .title = "Edit an adjacent line in alpha.txt", 1223 .description = "This patch can be cleanly merged by haxy, while git throws a **merge conflict**!", 1224 .labels = "merge", 1225 .status = .open, 1226 .alpha_edit = .{ .line = 2, .text = "adjust alpha beside the latest scatter edit" }, 1227 }, 1228 .{ 1229 .title = "Edit a conflicting line in alpha.txt", 1230 .description = "Both source and squash merges conflict with a different edit to the *same line* on master.", 1231 .labels = "merge", 1232 .status = .open, 1233 .alpha_edit = .{ .line = 3, .text = "replace alpha with a conflicting edit" }, 1234 }, 1235 }; 1236 1237 const users_dir = try std.Io.Dir.path.join(allocator, &.{ server_path, "users" }); 1238 defer allocator.free(users_dir); 1239 const patch_author = evt.CommitAuthor{ .name = "admin", .email = "admin@example.test" }; 1240 var patch_ids: [patch_data.len][evt.event_id_size]u8 = undefined; 1241 for (patch_data, 0..) |patch, i| { 1242 const timestamp: u64 = @intCast(500 + i * 10); 1243 patch_ids[i] = evt.EventWithId.randomId(random); 1244 const patch_hex = std.fmt.bytesToHex(patch_ids[i], .lower); 1245 const path = try fork.create(.{}, io, allocator, users_dir, .{ 1246 .id = patch_hex, 1247 .user_id = user_id.*, 1248 .repo_id = repo_id.*, 1249 .repo_user_id = repo_user_id.*, 1250 .title = patch.title, 1251 .description = patch.description, 1252 .labels = patch.labels, 1253 .target_branch = "master", 1254 .author = patch_author, 1255 .timestamp = timestamp, 1256 }); 1257 allocator.free(path); 1258 1259 // prepare the patch's base and file contents, then seed its commits and revision 1260 { 1261 var arena = std.heap.ArenaAllocator.init(allocator); 1262 defer arena.deinit(); 1263 const aa = arena.allocator(); 1264 var base_oid = (try target_repo.readRef(io, .{ .kind = .head, .name = "master" })) orelse return error.NotFound; 1265 if (patch.alpha_edit != null or patch.behind_master) { 1266 // v30 precedes the last scatter commit, even after the sample merge 1267 const tag_oid = (try target_repo.readRef(io, .{ .kind = .tag, .name = "v30" })) orelse return error.NotFound; 1268 var moment = try target_repo.core.latestMoment(); 1269 const state = rp.Repo(.xit, .{}).State(.read_only){ .core = &target_repo.core, .extra = .{ .moment = &moment } }; 1270 var tag = try obj.Object(.xit, .{}).init(state, io, allocator, &tag_oid); 1271 defer tag.deinit(); 1272 base_oid = switch (tag.content) { 1273 .tag => |value| value.target, 1274 else => return error.InvalidObject, 1275 }; 1276 } 1277 var contents: [3][]const u8 = undefined; 1278 const file_path: []const u8, const count: usize = if (patch.alpha_edit) |edit| blk: { 1279 // rev 29 first changes line 4; edit that line or the one above it 1280 contents[0] = try scatterContent(aa, 0, 28, edit); 1281 break :blk .{ "src/alpha.txt", 1 }; 1282 } else blk: { 1283 var writer = std.Io.Writer.Allocating.init(allocator); 1284 defer writer.deinit(); 1285 for (&contents, 0..) |*content, part| { 1286 try writer.writer.print("{s}: part {d}\n", .{ patch.title, part + 1 }); 1287 content.* = try aa.dupe(u8, writer.written()); 1288 } 1289 break :blk .{ "patch.txt", contents.len }; 1290 }; 1291 try seedPatchRevision(io, allocator, users_dir, user_id, &patch_ids[i], patch.title, patch_author, timestamp + 1, random, base_oid, file_path, contents[0..count], patch.removed_path); 1292 } 1293 const status = patch.status orelse continue; 1294 try pch.publish(.{}, io, allocator, users_dir, admin_repo, target_repo, .{ 1295 .id = patch_hex, 1296 .user_id = user_id.*, 1297 .repo_id = repo_id.*, 1298 .author = patch_author, 1299 .timestamp = timestamp + 6, 1300 }); 1301 1302 if (status == .merged) { 1303 try pch.mergeAndRemoveFork(.{}, io, allocator, users_dir, target_repo, .{ 1304 .id = patch_hex, 1305 .revision = .source, 1306 .author = patch_author, 1307 .timestamp = timestamp + 7, 1308 }); 1309 } else if (status != .open) { 1310 try evt.Patch.update(.{ .server = .{ .users_dir = users_dir } }, .xit, .{}, io, allocator, target_repo, &patch_ids[i], .{ .status = status }, patch_author); 1311 } 1312 } 1313 1314 // seed a small comment tree on the newest patch 1315 var comment_ids: [5][evt.event_id_size]u8 = undefined; 1316 for (&comment_ids) |*id| id.* = evt.EventWithId.randomId(random); 1317 const comment_bodies = [_][]const u8{ 1318 "This also needs to preserve the **executable bit** for files nested inside generated directories.", 1319 "I tested both paths:\n\n- the archive path\n- the direct-copy path\n\nBoth currently lose the mode.", 1320 "The `ArchiveWriter` is the right place to centralize it, since every exporter already goes through that layer.", 1321 "Please include a regression fixture with a *mix* of executable and ordinary files.", 1322 "I'll add that fixture and cover both supported archive formats:\n\n1. tar\n2. zip", 1323 }; 1324 var comments: [comment_ids.len]evt.EventWithId = undefined; 1325 for (&comments, 0..) |*comment, i| { 1326 comment.* = .{ 1327 .id = std.fmt.bytesToHex(comment_ids[i], .lower), 1328 .timestamp = @intCast(700 + i), 1329 .author = .{ .name = if (i % 2 == 0) "alice" else "bobby", .email = if (i % 2 == 0) "alice@example.test" else "bobby@example.test" }, 1330 .event = .{ .comment = .{ 1331 .thread_id = std.fmt.bytesToHex(patch_ids[patch_ids.len - 1], .lower), 1332 .parent_id = switch (i) { 1333 0, 1 => std.fmt.bytesToHex(patch_ids[patch_ids.len - 1], .lower), 1334 2, 4 => std.fmt.bytesToHex(comment_ids[0], .lower), 1335 3 => std.fmt.bytesToHex(comment_ids[2], .lower), 1336 else => unreachable, 1337 }, 1338 .body = comment_bodies[i], 1339 } }, 1340 }; 1341 } 1342 try evt.consume(.{ .server = .{ .users_dir = users_dir } }, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &comments); 1343 1344 // create divergent metadata edits on the next three patches 1345 var patch_arena = std.heap.ArenaAllocator.init(allocator); 1346 defer patch_arena.deinit(); 1347 const moment = try evt.currentMoment(.{}, target_repo); 1348 var values: [3]evt.Patch = undefined; 1349 for (1..4) |i| { 1350 const record = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &patch_arena, &patch_ids[i])) orelse return error.NotFound; 1351 values[i - 1] = record.event; 1352 } 1353 var ours_values = values; 1354 ours_values[0].title = "Drop the legacy configuration loader"; 1355 ours_values[0].labels = "cleanup config breaking"; 1356 const closed_description = try longDescription( 1357 patch_arena.allocator(), 1358 "## Summary\n\nCache parsed manifests for the lifetime of a command invocation and invalidate entries when their files change.", 1359 ); 1360 ours_values[1].description = closed_description; 1361 ours_values[2].description = "Add JSON output to `inspect` with versioned field names and deterministic object ordering."; 1362 var theirs_values = values; 1363 theirs_values[0].title = "Delete compatibility configuration support"; 1364 theirs_values[0].labels = "config maintenance"; 1365 theirs_values[1].description = "Keep a process-wide manifest cache shared by **every** command and refresh it after writes."; 1366 theirs_values[2].description = "Expose `inspect` results as newline-delimited JSON so callers can stream large repositories."; 1367 1368 const seed_tip = (try target_repo.readRef(io, evt.events_ref)) orelse return error.NotFound; 1369 const other_ref = xit.ref.Ref{ .kind = .head, .name = "haxy/patch-other" }; 1370 var ours = [_]evt.EventWithId{ 1371 .{ 1372 .id = std.fmt.bytesToHex(patch_ids[1], .lower), 1373 .timestamp = 800, 1374 .author = .{ .name = "alice", .email = "alice@example.test" }, 1375 .event = .{ .patch = ours_values[0] }, 1376 }, 1377 .{ 1378 .id = std.fmt.bytesToHex(patch_ids[2], .lower), 1379 .timestamp = 801, 1380 .author = .{ .name = "alice", .email = "alice@example.test" }, 1381 .event = .{ .patch = ours_values[1] }, 1382 }, 1383 .{ 1384 .id = std.fmt.bytesToHex(patch_ids[3], .lower), 1385 .timestamp = 802, 1386 .author = .{ .name = "alice", .email = "alice@example.test" }, 1387 .event = .{ .patch = ours_values[2] }, 1388 }, 1389 }; 1390 1391 var theirs = ours; 1392 theirs[0].timestamp = 810; 1393 theirs[0].author = .{ .name = "bobby", .email = "bobby@example.test" }; 1394 theirs[0].event.patch = theirs_values[0]; 1395 theirs[1].timestamp = 811; 1396 theirs[1].author = .{ .name = "bobby", .email = "bobby@example.test" }; 1397 theirs[1].event.patch = theirs_values[1]; 1398 theirs[2].timestamp = 812; 1399 theirs[2].author = .{ .name = "bobby", .email = "bobby@example.test" }; 1400 theirs[2].event.patch = theirs_values[2]; 1401 1402 try evt.consume(.{ .server = .{ .users_dir = users_dir } }, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &ours); 1403 try commitEventsAtRef(io, allocator, target_repo, other_ref, &theirs, seed_tip); 1404 { 1405 var merge = try target_repo.mergeAtRef(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = other_ref }} } } }, evt.events_ref, null); 1406 defer merge.deinit(); 1407 if (merge.result != .success) return error.MergeFailed; 1408 } 1409 try target_repo.removeBranch(io, .{ .name = other_ref.name }); 1410 try evt.consume(.{ .server = .{ .users_dir = users_dir } }, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &.{}); 1411 try pch.writeBranchPatch(.{ .server = .{ .users_dir = users_dir } }, .xit, .{}, io, allocator, target_repo, std.fmt.bytesToHex(evt.EventWithId.randomId(random), .lower), .{ 1412 .title = "Merge the existing feature branch", 1413 .description = "This patch tracks the `feature` branch in this repo without creating a fork.", 1414 .labels = "feature", 1415 .source_branch = "feature", 1416 .target_branch = "master", 1417 }, null, patch_author); 1418 1419 // a push onto the branch that patch tracks, so the undo tab shows the 1420 // action and the patch refresh it sets off 1421 try seedPush(io, allocator, target_repo, users_dir, patch_author); 1422 try pch.refreshBranches(.{ .server = .{ .users_dir = users_dir } }, .xit, .{}, io, allocator, target_repo, null, null); 1423 } 1424 1425 // stand in for a client push, which the fixture has no server to receive: one 1426 // transaction moves the branch, refreshes the patches tracking it and records 1427 // the action, the way receive-pack does 1428 fn seedPush(io: std.Io, allocator: std.mem.Allocator, repo: *rp.Repo(.xit, .{}), users_dir: []const u8, author: evt.CommitAuthor) !void { 1429 const Repo = rp.Repo(.xit, .{}); 1430 const DB = Repo.DB; 1431 const Ctx = struct { 1432 core: *Repo.Core, 1433 io: std.Io, 1434 allocator: std.mem.Allocator, 1435 users_dir: []const u8, 1436 author: evt.CommitAuthor, 1437 1438 pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void { 1439 const opts: rp.RepoOpts(.xit) = .{}; 1440 var moment = try DB.HashMap(.read_write).init(cursor.*); 1441 const state = Repo.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; 1442 var arena = std.heap.ArenaAllocator.init(ctx.allocator); 1443 defer arena.deinit(); 1444 const aa = arena.allocator(); 1445 1446 // a null tree keeps the parent's content, so the branch advances 1447 // without the fixture having to build one 1448 const author_line = try aa.print("{s} <{s}>", .{ ctx.author.name, ctx.author.email }); 1449 const feature_old = (try rf.readRecur(.xit, opts, state.readOnly(), ctx.io, .{ .ref = .{ .kind = .head, .name = "feature" } })) orelse return error.NotFound; 1450 const feature_new = try obj.writeCommit(.xit, opts, state, ctx.io, ctx.allocator, .{ 1451 .message = "Revise the feature branch", 1452 .author = author_line, 1453 .timestamp = 820, 1454 }, null, .{ .kind = .head, .name = "feature" }); 1455 1456 // a branch the push creates has no old tip, so its range is open 1457 try bch.add(.xit, opts, state, ctx.io, .{ .name = "docs" }); 1458 const docs_new = (try rf.readRecur(.xit, opts, state.readOnly(), ctx.io, .{ .ref = .{ .kind = .head, .name = "docs" } })) orelse return error.NotFound; 1459 1460 const updates = [_]xit.net_server_receive_pack.AppliedRefUpdate{ 1461 .{ 1462 .ref_name = try aa.dupe(u8, "refs/heads/feature"), 1463 .old_oid = try aa.dupe(u8, &feature_old), 1464 .new_oid = try aa.dupe(u8, &feature_new), 1465 }, 1466 .{ 1467 .ref_name = try aa.dupe(u8, "refs/heads/docs"), 1468 .old_oid = try aa.dupe(u8, &@as([hash.hexLen(opts.hash)]u8, @splat('0'))), 1469 .new_oid = try aa.dupe(u8, &docs_new), 1470 }, 1471 }; 1472 1473 _ = try pch.refreshBranchesInTransaction(.{ .server = .{ .users_dir = ctx.users_dir } }, opts, state, &moment, ctx.io, ctx.allocator, &updates, null, null); 1474 try push.writeUndo(opts, state, ctx.io, ctx.allocator, ctx.author, &updates); 1475 } 1476 }; 1477 1478 try transaction(io, repo, Ctx{ .core = &repo.core, .io = io, .allocator = allocator, .users_dir = users_dir, .author = author }); 1479 } 1480 1481 // commit `events` onto `ref`, rooted at `parent`, as one transaction. 1482 // consume always roots a new branch at nothing, so the divergent fixtures 1483 // write their side branch here instead. nothing is consumed, so it records 1484 // xit's own commit action rather than one of haxy's event actions 1485 fn commitEventsAtRef( 1486 io: std.Io, 1487 allocator: std.mem.Allocator, 1488 repo: *rp.Repo(.xit, .{}), 1489 ref: xit.ref.Ref, 1490 events: []const evt.EventWithId, 1491 parent: [hash.hexLen(.sha1)]u8, 1492 ) !void { 1493 const Repo = rp.Repo(.xit, .{}); 1494 const DB = Repo.DB; 1495 const Ctx = struct { 1496 core: *Repo.Core, 1497 io: std.Io, 1498 allocator: std.mem.Allocator, 1499 ref: xit.ref.Ref, 1500 events: []const evt.EventWithId, 1501 parent: [hash.hexLen(.sha1)]u8, 1502 1503 pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void { 1504 const opts: rp.RepoOpts(.xit) = .{}; 1505 var moment = try DB.HashMap(.read_write).init(cursor.*); 1506 const state = Repo.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; 1507 try evt.commitEvents(.xit, opts, state, ctx.io, ctx.allocator, ctx.ref, ctx.events, .{ctx.parent}); 1508 const tip = (try xit.ref.readRecur(.xit, opts, state.readOnly(), ctx.io, .{ .ref = ctx.ref })) orelse return error.NotFound; 1509 try xit.undo.write(opts, state, std.Io.Timestamp.now(ctx.io, .real).toSeconds(), .{ 1510 .commit = try .init("seed conflicting events", tip, opts.max_read_size), 1511 }); 1512 } 1513 }; 1514 1515 try transaction(io, repo, Ctx{ 1516 .core = &repo.core, 1517 .io = io, 1518 .allocator = allocator, 1519 .ref = ref, 1520 .events = events, 1521 .parent = parent, 1522 }); 1523 } 1524 1525 // append `ctx` to the repo's history as one transaction. the fixtures write a 1526 // few states the normal paths have no way to produce 1527 // fixtures commit directly, so the ref tips are indexed by hand. a fork gets 1528 // no commit index, as in production. 1529 const Reindex = struct { 1530 io: std.Io, 1531 allocator: std.mem.Allocator, 1532 core: *rp.Repo(.xit, .{}).Core, 1533 commits: bool, 1534 1535 pub fn run(ctx: @This(), cursor: *rp.Repo(.xit, .{}).DB.Cursor(.read_write)) !void { 1536 var moment = try rp.Repo(.xit, .{}).DB.HashMap(.read_write).init(cursor.*); 1537 const state = rp.Repo(.xit, .{}).State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; 1538 _ = try find.refreshInTransaction(.{}, state, &moment, ctx.io, ctx.allocator, null); 1539 if (ctx.commits) _ = try srch_cmmt.refreshInTransaction(.{}, state, &moment, ctx.io, ctx.allocator, &.{}, null); 1540 } 1541 }; 1542 1543 fn transaction(io: std.Io, repo: *rp.Repo(.xit, .{}), ctx: anytype) !void { 1544 const DB = rp.Repo(.xit, .{}).DB; 1545 try repo.core.db_file.lock(io, .exclusive); 1546 defer repo.core.db_file.unlock(io); 1547 1548 const history = try DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); 1549 try history.appendContext(.{ .slot = try history.getSlot(-1) }, ctx); 1550 } 1551 1552 // recursively copy the contents of src_dir into dest_dir 1553 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 1554 var iter = src_dir.iterate(); 1555 while (try iter.next(io)) |entry| { 1556 switch (entry.kind) { 1557 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 1558 .directory => { 1559 try dest_dir.createDirPath(io, entry.name); 1560 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1561 defer dest_entry_dir.close(io); 1562 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1563 defer src_entry_dir.close(io); 1564 try copyDir(io, src_entry_dir, dest_entry_dir); 1565 }, 1566 else => {}, 1567 } 1568 } 1569 } 1570