feat: query project files via git (part 1)

This commit is contained in:
CJ van den Berg 2025-04-21 21:43:29 +02:00
parent 4cb84e25b3
commit f76085325a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 75 additions and 21 deletions

View file

@ -29,7 +29,7 @@ pub fn create(
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
};
try tui.message_filters().add(MessageFilter.bind(self, receive_git));
git.workspace_path() catch {};
git.workspace_path(0) catch {};
return Widget.to(self);
}
@ -51,11 +51,11 @@ fn process_git(
m: tp.message,
) MessageFilter.Error!bool {
var branch: []const u8 = undefined;
if (try match(m.buf, .{ any, "workspace_path", null_ })) {
self.branch = try self.allocator.dupe(u8, "null");
} else if (try match(m.buf, .{ any, "workspace_path", string })) {
git.current_branch() catch {};
} else if (try match(m.buf, .{ any, "current_branch", extract(&branch) })) {
if (try match(m.buf, .{ any, any, "workspace_path", null_ })) {
// do nothing, we do not have a git workspace
} else if (try match(m.buf, .{ any, any, "workspace_path", string })) {
git.current_branch(0) catch {};
} else if (try match(m.buf, .{ any, any, "current_branch", extract(&branch) })) {
if (self.branch) |p| self.allocator.free(p);
self.branch = try self.allocator.dupe(u8, branch);
} else {