Changes
2 changed files (+67/-20)
-
-
@@ -21,6 +21,7 @@ pub const Code = enum(u8) {out_of_memory = 3, stdout_write_error = 4, filename_error = 5, dir_open_error = 6, pub fn to_u8(self: @This()) u8 { return @intFromEnum(self);
-
-
-
@@ -56,10 +56,16 @@ const Options = struct {/// Wayland socket to bind. wayland_socket: ?WaylandSocket = null, /// Enable writes to "$PROJECT/.git". /// Git directory to bind mount. git_dir: ?[]const u8 = null, /// Enable writes to "git_dir". mutable_git_dir: bool = false, /// Enable writes to "$PROJECT/.jj". /// JJ directory to bind mount. jj_dir: ?[]const u8 = null, /// Enable writes to "jj_dir". mutable_jj_dir: bool = false, const WriteError = std.Io.Writer.Error || std.mem.Allocator.Error;
-
@@ -118,22 +124,26 @@ const Options = struct {.path = "/home/workerbee/project", }); if (!self.mutable_git_dir) { try json.objectField("git"); try json.write(incus.DiskDevice{ .source = try std.fs.path.join(allocator, &.{ project_dir, ".git" }), .path = "/home/workerbee/project/.git", .readonly = true, }); if (self.git_dir) |git_dir| { if (!self.mutable_git_dir) { try json.objectField("git"); try json.write(incus.DiskDevice{ .source = git_dir, .path = "/home/workerbee/project/.git", .readonly = true, }); } } if (!self.mutable_jj_dir) { try json.objectField("jj"); try json.write(incus.DiskDevice{ .source = try std.fs.path.join(allocator, &.{ project_dir, ".jj" }), .path = "/home/workerbee/project/.jj", .readonly = true, }); if (self.jj_dir) |jj_dir| { if (!self.mutable_jj_dir) { try json.objectField("jj"); try json.write(incus.DiskDevice{ .source = jj_dir, .path = "/home/workerbee/project/.jj", .readonly = true, }); } } }
-
@@ -243,6 +253,42 @@ pub fn run(allocator: std.mem.Allocator, args: *std.process.ArgIterator) !exit.C}, }; var dir = std.fs.cwd().openDir(path, .{}) catch |err| { std.log.err("Unable to open project directory: {t}", .{err}); return .dir_open_error; }; defer dir.close(); configure_git_dir: { var git_dir = dir.openDir(".git", .{}) catch |err| switch (err) { std.fs.Dir.OpenError.FileNotFound => break :configure_git_dir, else => { std.log.err("Unable to open .git at {s}: {t}", .{ realpath, err }); return .dir_open_error; }, }; defer git_dir.close(); options.git_dir = dir.realpathAlloc(allocator, ".git") catch { return .out_of_memory; }; } configure_jj_dir: { var jj_dir = dir.openDir(".jj", .{}) catch |err| switch (err) { std.fs.Dir.OpenError.FileNotFound => break :configure_jj_dir, else => { std.log.err("Unable to open .jj at {s}: {t}", .{ realpath, err }); return .dir_open_error; }, }; defer jj_dir.close(); options.jj_dir = dir.realpathAlloc(allocator, ".jj") catch { return .out_of_memory; }; } options.project_dir = realpath; continue; }
-
@@ -276,13 +322,13 @@ pub fn run(allocator: std.mem.Allocator, args: *std.process.ArgIterator) !exit.Creturn .incorrect_usage; } if (options.mutable_git_dir and options.project_dir == null) { std.log.err("--mutable=git requires --project option", .{}); if (options.mutable_git_dir and options.git_dir == null) { std.log.err("--mutable=git requires .git directory inside --project directory", .{}); return .incorrect_usage; } if (options.mutable_jj_dir and options.project_dir == null) { std.log.err("--mutable=jj requires --project option", .{}); if (options.mutable_jj_dir and options.jj_dir == null) { std.log.err("--mutable=jj requires .jj directory inside --project directory", .{}); return .incorrect_usage; }
-