╭ changed ────╮ │src/serve.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────╮ │ 6 pub const Options = struct { │ │ 7 http_listen: []const u8, │ │ 8 ssh_listen: ?[]const u8, │ │ 9 - project_root: []const u8, │ │ 9 + data_dir: []const u8, │ │10 }; │ │11 │ │12 const ListenAddress = struct {│ ╰──────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │23 options: Options, │ │24 err: *std.Io.Writer, │ │25 ) !void { │ │26 - const project_root = try std.fs.path.resolve(allocator, &.{ cwd_path, options.project_root });│ │27 - defer allocator.free(project_root); │ │26 + const data_dir = try std.fs.path.resolve(allocator, &.{ cwd_path, options.data_dir }); │ │27 + defer allocator.free(data_dir); │ │28 + const repo_root = try std.fs.path.resolve(allocator, &.{ data_dir, "repos" }); │ │29 + defer allocator.free(repo_root); │ │30 + │ │31 + try std.Io.Dir.cwd().createDirPath(io, repo_root); │ │32 │ │33 if (options.ssh_listen) |ssh_listen| { │ │34 const HttpContext = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────╮ │35 io: std.Io, │ │36 allocator: std.mem.Allocator,│ │33 - project_root: []const u8, │ │37 + repo_root: []const u8, │ │38 http_listen: []const u8, │ │39 err: *std.Io.Writer, │ │40 │ ╰─────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │41 fn run(ctx: @This()) !void { │ │38 - try runHttpListener(repo_kind, any_repo_opts, ctx.io, ctx.allocator, ctx.project_root, ctx.http_listen, ctx.err);│ │42 + try runHttpListener(repo_kind, any_repo_opts, ctx.io, ctx.allocator, ctx.repo_root, ctx.http_listen, ctx.err); │ │43 } │ │44 }; │ │45 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │46 const http_thread = try std.Thread.spawn(.{}, HttpContext.run, .{HttpContext{│ │47 .io = io, │ │48 .allocator = allocator, │ │45 - .project_root = project_root, │ │49 + .repo_root = repo_root, │ │50 .http_listen = options.http_listen, │ │51 .err = err, │ │52 }}); │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │53 defer http_thread.join(); │ │54 │ │51 - try runSshListener(repo_kind, any_repo_opts, io, allocator, project_root, ssh_listen, err); │ │55 + try runSshListener(repo_kind, any_repo_opts, io, allocator, repo_root, ssh_listen, err); │ │56 } else { │ │53 - try runHttpListener(repo_kind, any_repo_opts, io, allocator, project_root, options.http_listen, err);│ │57 + try runHttpListener(repo_kind, any_repo_opts, io, allocator, repo_root, options.http_listen, err); │ │58 } │ │59 } │ │60 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────╮ │63 comptime any_repo_opts: rp.AnyRepoOpts(repo_kind),│ │64 io: std.Io, │ │65 allocator: std.mem.Allocator, │ │62 - project_root: []const u8, │ │66 + repo_root: []const u8, │ │67 http_listen: []const u8, │ │68 err: *std.Io.Writer, │ │69 ) !void { │ ╰──────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │72 var net_server = try address.listen(io, .{ .reuse_address = true }); │ │73 defer net_server.deinit(io); │ │74 │ │71 - try err.print("serving HTTP on {s}, project root {s}\n", .{ http_listen, project_root });│ │75 + try err.print("serving HTTP on {s}, repo root {s}\n", .{ http_listen, repo_root }); │ │76 try err.flush(); │ │77 │ │78 var send_buffer = [_]u8{0} ** any_repo_opts.net_buffer_size; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 96 else => |e| return e, │ │ 97 }; │ │ 98 │ │ 95 - handleRequest(repo_kind, any_repo_opts, io, allocator, project_root, &http_server, &request) catch |request_err| {│ │ 99 + handleRequest(repo_kind, any_repo_opts, io, allocator, repo_root, &http_server, &request) catch |request_err| { │ │100 try err.print("request failed: {s}\n", .{@errorName(request_err)}); │ │101 try err.flush(); │ │102 if (http_server.reader.state == .received_head) { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────╮ │115 comptime any_repo_opts: rp.AnyRepoOpts(repo_kind),│ │116 io: std.Io, │ │117 allocator: std.mem.Allocator, │ │114 - project_root: []const u8, │ │118 + repo_root: []const u8, │ │119 http_server: *std.http.Server, │ │120 request: *std.http.Server.Request, │ │121 ) !void { │ ╰───────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯