╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1323 theirs[2].event.patch = theirs_values[2]; 1324 1325 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &ours); 1326 var json: std.Io.Writer.Allocating = .init(allocator); 1327 defer json.deinit(); 1328 for (theirs, 0..) |event, i| { 1329 json.clearRetainingCapacity(); 1330 try std.json.Stringify.value(event, .{}, &json.writer); 1331 const author = try std.fmt.allocPrint(allocator, "{s} <{s}>", .{ event.author.name, event.author.email }); 1332 defer allocator.free(author); 1333 _ = try target_repo.commitAtRef(io, allocator, .{ 1334 .author = author, 1335 .message = json.written(), 1336 .timestamp = event.timestamp, 1337 .parent_oids = if (i == 0) &.{seed_tip} else null, 1338 }, null, other_ref); 1339 } 1340 { 1341 var merge = try target_repo.mergeAtRef(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = other_ref }} } } }, evt.events_ref, null); 1342 defer merge.deinit(); 1343 if (merge.result != .success) return error.MergeFailed; 1344 } 1345 try target_repo.removeBranch(io, .{ .name = other_ref.name }); 1346 try evt.consume(.server, .repo, .xit, .{}, io, allocator, target_repo, evt.events_ref, &.{}); 1347 try pch.writeBranchPatch(.server, .xit, .{}, io, allocator, target_repo, std.fmt.bytesToHex(evt.EventWithId.randomId(random), .lower), .{ 1348 .title = "Merge the existing feature branch", 1349 .description = "This patch tracks the feature branch in this repo without creating a fork.", 1350 .tags = "feature", 1351 .source_branch = "feature", 1352 .target_branch = "master", 1353 }, null, patch_author); 1354 } 1355 1356 // recursively copy the contents of src_dir into dest_dir 1357 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 1358 var iter = src_dir.iterate(); 1359 while (try iter.next(io)) |entry| { 1360 switch (entry.kind) { 1361 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 1362 .directory => { 1363 try dest_dir.createDirPath(io, entry.name); 1364 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1365 defer dest_entry_dir.close(io); 1366 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 1367 defer src_entry_dir.close(io); 1368 try copyDir(io, src_entry_dir, dest_entry_dir); 1369 }, 1370 else => {}, 1371 } 1372 } 1373 } 1374