╭ changed ╮ │README.md│ ╰─────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │18 It can't do much right now...it's just a git server at the moment. If you want to try it out, do this:│ │19 │ │20 ``` │ │21 -mkdir server │ │21 +mkdir -p server │ │22 ./zig-out/bin/haxy serve --http-listen 127.0.0.1:8080 --data-dir server │ │23 ``` │ │24 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ────╮ │build.zig.zon│ ╰─────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 3 .version = "0.0.0", │ │ 4 .dependencies = .{ │ │ 5 .xit = .{ │ │ 6 - .url = "git+https://github.com/xit-vcs/xit#d852314d281940090f3f0a8c5b8d97437a4024d9",│ │ 7 - .hash = "xit-0.0.0-Ub3nDORQTwGhcCHiWDdUxsz4EnIRZp0ehyAi7DgpjDeG", │ │ 6 + .url = "git+https://github.com/xit-vcs/xit#cc36758f73791508019db1cc39a377921f6c360f",│ │ 7 + .hash = "xit-0.0.0-Ub3nDAVRTwHYtkR5TgYJ7dYhRfhJg1ysB5PT3k0l7pEE", │ │ 8 }, │ │ 9 }, │ │10 .paths = .{ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ────╮ │src/serve.zig│ ╰─────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │23 options: Options, │ │24 err: *std.Io.Writer, │ │25 ) !void { │ │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); │ │26 + // create the data dir │ │27 + │ │28 + const data_dir_path = try std.fs.path.resolve(allocator, &.{ cwd_path, options.data_dir }); │ │29 + defer allocator.free(data_dir_path); │ │30 + │ │31 + const data_dir = try std.Io.Dir.cwd().createDirPathOpen(io, data_dir_path, .{}); │ │32 + defer data_dir.close(io); │ │33 + │ │34 + // create a db file just as a test for now │ │35 + { │ │36 + const db_file = try data_dir.createFile(io, "db", .{ .truncate = true, .lock = .exclusive, .read = true });│ │37 + defer db_file.close(io); │ │38 + │ │39 + var buffer = std.Io.Writer.Allocating.init(allocator); │ │40 + defer buffer.deinit(); │ │41 + │ │42 + const DB = xit.db.Database(.buffered_file, u160); │ │43 + var db = try DB.init(.{ .io = io, .file = db_file, .buffer = &buffer }); │ │44 + │ │45 + const db_array = try DB.ArrayList(.read_write).init(db.rootCursor()); │ │46 + try db_array.append(.{ .bytes = "this is a test" }); │ │47 + } │ │48 + │ │49 + // create the repos dir │ │50 + │ │51 + const repo_root_path = try std.fs.path.resolve(allocator, &.{ data_dir_path, "repos" }); │ │52 + defer allocator.free(repo_root_path); │ │53 + │ │54 + try std.Io.Dir.cwd().createDirPath(io, repo_root_path); │ │55 │ │31 - try std.Io.Dir.cwd().createDirPath(io, repo_root); │ │56 + // create http listener │ │57 │ │58 const http_listen_address = try parseListenAddress(options.http_listen); │ │59 const http_address = try std.Io.net.IpAddress.parseIp4(http_listen_address.host, http_listen_address.port); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │60 var http_server = try http_address.listen(io, .{ .reuse_address = true }); │ │61 defer http_server.deinit(io); │ │62 │ │38 - try err.print("serving HTTP on {s}, repo root {s}\n", .{ options.http_listen, repo_root }); │ │63 + try err.print("serving HTTP on {s}, repo root {s}\n", .{ options.http_listen, repo_root_path });│ │64 try err.flush(); │ │65 │ │66 var tasks: std.Io.Group = .init; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │67 defer tasks.cancel(io); │ │68 + │ │69 + runHttpListener(repo_kind, any_repo_opts, io, allocator, repo_root_path, &http_server, &tasks, err);│ │70 │ │44 - runHttpListener(repo_kind, any_repo_opts, io, allocator, repo_root, &http_server, &tasks, err); │ │71 + // create ssh listener │ │72 │ │73 var ssh_server: ?std.Io.net.Server = null; │ │74 defer if (ssh_server) |*server| server.deinit(io); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │78 const ssh_address = try std.Io.net.IpAddress.parseIp4(ssh_listen_address.host, ssh_listen_address.port); │ │79 ssh_server = try ssh_address.listen(io, .{ .reuse_address = true }); │ │80 │ │54 - try err.print("serving SSH helper connections on {s}, repo root {s}\n", .{ ssh_listen, repo_root }); │ │81 + try err.print("serving SSH helper connections on {s}, repo root {s}\n", .{ ssh_listen, repo_root_path });│ │82 try err.flush(); │ │83 │ │84 if (ssh_server) |*server| { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │58 - runSshListener(repo_kind, any_repo_opts, io, allocator, repo_root, server, &tasks, err); │ │85 + runSshListener(repo_kind, any_repo_opts, io, allocator, repo_root_path, server, &tasks, err);│ │86 } │ │87 } │ │88 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────╮ │ 94 comptime any_repo_opts: rp.AnyRepoOpts(repo_kind),│ │ 95 io: std.Io, │ │ 96 allocator: std.mem.Allocator, │ │ 70 - repo_root: []const u8, │ │ 97 + repo_root_path: []const u8, │ │ 98 net_server: *std.Io.net.Server, │ │ 99 tasks: *std.Io.Group, │ │100 err: *std.Io.Writer, │ ╰───────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────╮ │102 const Listener = struct { │ │103 io: std.Io, │ │104 allocator: std.mem.Allocator, │ │ 78 - repo_root: []const u8, │ │105 + repo_root_path: []const u8, │ │106 net_server: *std.Io.net.Server,│ │107 tasks: *std.Io.Group, │ │108 err: *std.Io.Writer, │ ╰────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────╮ │117 const Connection = struct { │ │118 io: std.Io, │ │119 allocator: std.mem.Allocator,│ │ 93 - repo_root: []const u8, │ │120 + repo_root_path: []const u8, │ │121 stream: std.Io.net.Stream, │ │122 err: *std.Io.Writer, │ │123 │ ╰──────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯