╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1256 .body = comment_bodies[i], 1257 } }, 1258 }; 1259 } 1260 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &comments); 1261 1262 // create divergent metadata edits on the next three patches 1263 var patch_arena = std.heap.ArenaAllocator.init(allocator); 1264 defer patch_arena.deinit(); 1265 const moment = try evt.currentMoment(.{}, target_repo); 1266 var values: [3]evt.Patch = undefined; 1267 for (1..4) |i| { 1268 const record = (try evt.Patch.readById(evt.EventDB(.sha1), .sha1, moment, &patch_arena, &patch_ids[i])) orelse return error.NotFound; 1269 values[i - 1] = record.event; 1270 } 1271 var ours_values = values; 1272 ours_values[0].title = "Drop the legacy configuration loader"; 1273 ours_values[0].tags = "cleanup config breaking"; 1274 const closed_description = try longDescription( 1275 patch_arena.allocator(), 1276 "Cache parsed manifests for the lifetime of a command invocation and invalidate entries when their files change.", 1277 ); 1278 ours_values[1].description = closed_description; 1279 ours_values[2].description = "Add JSON output to inspect with versioned field names and deterministic object ordering."; 1280 var theirs_values = values; 1281 theirs_values[0].title = "Delete compatibility configuration support"; 1282 theirs_values[0].tags = "config maintenance"; 1283 theirs_values[1].description = "Keep a process-wide manifest cache shared by every command and refresh it after writes."; 1284 theirs_values[2].description = "Expose inspect results as newline-delimited JSON so callers can stream large repositories."; 1285 1286 const seed_tip = (try target_repo.readRef(io, evt.events_ref)) orelse return error.NotFound; 1287 const other_ref = xit.ref.Ref{ .kind = .head, .name = "haxy/patch-other" }; 1288 var ours = [_]evt.EventWithId{ 1289 .{ 1290 .id = std.fmt.bytesToHex(patch_ids[1], .lower), 1291 .timestamp = 800, 1292 .author = .{ .name = "alice", .email = "alice@example.test" }, 1293 .event = .{ .patch = ours_values[0] }, 1294 }, 1295 .{ 1296 .id = std.fmt.bytesToHex(patch_ids[2], .lower), 1297 .timestamp = 801, 1298 .author = .{ .name = "alice", .email = "alice@example.test" }, 1299 .event = .{ .patch = ours_values[1] }, 1300 }, 1301 .{ 1302 .id = std.fmt.bytesToHex(patch_ids[3], .lower), 1303 .timestamp = 802, 1304 .author = .{ .name = "alice", .email = "alice@example.test" }, 1305 .event = .{ .patch = ours_values[2] }, 1306 }, 1307 }; 1308 1309 var theirs = ours; 1310 theirs[0].timestamp = 810; 1311 theirs[0].author = .{ .name = "bob", .email = "bob@example.test" }; 1312 theirs[0].event.patch = theirs_values[0]; 1313 theirs[1].timestamp = 811; 1314 theirs[1].author = .{ .name = "bob", .email = "bob@example.test" }; 1315 theirs[1].event.patch = theirs_values[1]; 1316 theirs[2].timestamp = 812; 1317 theirs[2].author = .{ .name = "bob", .email = "bob@example.test" }; 1318 theirs[2].event.patch = theirs_values[2]; 1319 1320 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &ours); 1321 var json: std.Io.Writer.Allocating = .init(allocator); 1322 defer json.deinit(); 1323 for (theirs, 0..) |event, i| { 1324 json.clearRetainingCapacity(); 1325 try std.json.Stringify.value(event, .{}, &json.writer); 1326 const author = try std.fmt.allocPrint(allocator, "{s} <{s}>", .{ event.author.name, event.author.email }); 1327 defer allocator.free(author); 1328 _ = try target_repo.commitAtRef(io, allocator, .{ 1329 .author = author, 1330 .message = json.written(), 1331 .timestamp = event.timestamp, 1332 .parent_oids = if (i == 0) &.{seed_tip} else null, 1333 }, null, other_ref); 1334 } 1335 { 1336 var merge = try target_repo.mergeAtRef(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = other_ref }} } } }, evt.events_ref, null); 1337 defer merge.deinit(); 1338 if (merge.result != .success) return error.MergeFailed; 1339 } 1340 try target_repo.removeBranch(io, .{ .name = other_ref.name }); 1341 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &.{}); 1342 try pch.writeBranchPatch(.server, .xit, .{}, io, allocator, target_repo, std.fmt.bytesToHex(evt.EventWithId.randomId(random), .lower), .{ 1343 .title = "Merge the existing feature branch", 1344 .description = "This patch tracks the feature branch in this repo without creating a fork.", 1345 .tags = "feature", 1346 .source_branch = "feature", 1347 .target_branch = "master", 1348 }, null, patch_author); 1349 } 1350 1351 // recursively copy the contents of src_dir into dest_dir 1352 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 1353 var iter = src_dir.iterate(); 1354 while (try iter.next(io)) |entry| { 1355 switch (entry.kind) { 1356 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 1357 .directory => { 1358 try dest_dir.createDirPath(io, entry.name); 1359 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1360 defer dest_entry_dir.close(io); 1361 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1362 defer src_entry_dir.close(io); 1363 try copyDir(io, src_entry_dir, dest_entry_dir); 1364 }, 1365 else => {}, 1366 } 1367 } 1368 } 1369