╭─────────────╮
│scroll to top│
╰─────────────╯
╭ net.zig ──────────────────────────────────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰───────────────────────────────────────────────────────────────╯
1566 .stderr = .ignore,
1567 });
1568 const term = try process.wait(io);
1569 if (term != .exited) {
1570 return error.GitCommandFailed;
1571 }
1572 } else {
1573 const ssh_cmd_maybe: ?[]const u8 = if (is_ssh) blk: {
1574 const known_hosts_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "known_hosts" });
1575 defer allocator.free(known_hosts_path);
1576
1577 const priv_key_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "key" });
1578 defer allocator.free(priv_key_path);
1579
1580 break :blk try std.fmt.allocPrint(allocator, "ssh -o UserKnownHostsFile=\"{s}\" -o IdentityFile=\"{s}\"", .{ known_hosts_path, priv_key_path });
1581 } else null;
1582 defer if (ssh_cmd_maybe) |ssh_cmd| allocator.free(ssh_cmd);
1583
1584 try client_repo.push(
1585 io,
1586 allocator,
1587 "origin",
1588 "master",
1589 false,
1590 .{ .wire = .{ .ssh = .{
1591 .command = ssh_cmd_maybe,
1592 .receive_pack_command = receive_pack_command,
1593 } } },
1594 );
1595
1596 if (transport_def == .file) {
1597 // update the working dir
1598 try server_repo.restore(io, allocator, ".");
1599 }
1600 }
1601
1602 // make sure push was successful
1603 {
1604 const oid_master = (try server_repo.readRef(io, .{ .kind = .head, .name = "master" })).?;
1605 try std.testing.expectEqualStrings(&commit2, &oid_master);
1606
1607 const hello_txt = try temp_dir.openFile(io, "repos/server/hello.txt", .{});
1608 defer hello_txt.close(io);
1609 }
1610 }
1611
1612 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void {
1613 var iter = src_dir.iterate();
1614 while (try iter.next(io)) |entry| {
1615 switch (entry.kind) {
1616 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}),
1617 .directory => {
1618 try dest_dir.createDirPath(io, entry.name);
1619 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false });
1620 defer dest_entry_dir.close(io);
1621 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false });
1622 defer src_entry_dir.close(io);
1623 try copyDir(io, src_entry_dir, dest_entry_dir);
1624 },
1625 else => {},
1626 }
1627 }
1628 }
1629