fix: don't run git status if we don't have a git working directory
closes #390
This commit is contained in:
parent
6e9e00e142
commit
462cc06e2e
1 changed files with 28 additions and 12 deletions
|
|
@ -693,8 +693,14 @@ pub fn get_mru_position(self: *Self, from: tp.pid_ref, file_path: []const u8) Cl
|
|||
|
||||
pub fn request_vcs_status(self: *Self, from: tp.pid_ref) ClientError!void {
|
||||
switch (self.state.status) {
|
||||
.none => return error.ClientFailed,
|
||||
.failed => return,
|
||||
.none => switch (self.state.workspace_path) {
|
||||
.running => {
|
||||
if (self.status_request) |_| return;
|
||||
self.status_request = from.clone();
|
||||
},
|
||||
else => return error.ClientFailed,
|
||||
},
|
||||
.running => {
|
||||
if (self.status_request) |_| return;
|
||||
self.status_request = from.clone();
|
||||
|
|
@ -708,6 +714,17 @@ pub fn request_vcs_status(self: *Self, from: tp.pid_ref) ClientError!void {
|
|||
};
|
||||
},
|
||||
}
|
||||
switch (self.state.vcs_new_or_modified_files) {
|
||||
.done => {
|
||||
for (self.new_or_modified_files.items) |file| self.allocator.free(file.path);
|
||||
self.new_or_modified_files.clearRetainingCapacity();
|
||||
self.state.vcs_new_or_modified_files = .running;
|
||||
git.new_or_modified_files(@intFromPtr(self)) catch {
|
||||
self.state.vcs_new_or_modified_files = .failed;
|
||||
};
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn request_tasks(self: *Self, from: tp.pid_ref) ClientError!void {
|
||||
|
|
@ -2383,17 +2400,6 @@ pub fn query_git(self: *Self) void {
|
|||
git.current_branch(@intFromPtr(self)) catch {
|
||||
self.state.current_branch = .failed;
|
||||
};
|
||||
self.state.status = .running;
|
||||
git.status(@intFromPtr(self)) catch {
|
||||
self.state.status = .failed;
|
||||
};
|
||||
// TODO: This needs to be invoked when there are identified changes in the fs
|
||||
for (self.new_or_modified_files.items) |file| self.allocator.free(file.path);
|
||||
self.new_or_modified_files.clearRetainingCapacity();
|
||||
self.state.vcs_new_or_modified_files = .running;
|
||||
git.new_or_modified_files(@intFromPtr(self)) catch {
|
||||
self.state.vcs_new_or_modified_files = .failed;
|
||||
};
|
||||
}
|
||||
|
||||
fn start_walker(self: *Self) void {
|
||||
|
|
@ -2422,6 +2428,16 @@ pub fn process_git(self: *Self, parent: tp.pid_ref, m: tp.message) (OutOfMemoryE
|
|||
git.workspace_files(@intFromPtr(self)) catch {
|
||||
self.state.workspace_files = .failed;
|
||||
};
|
||||
self.state.status = .running;
|
||||
git.status(@intFromPtr(self)) catch {
|
||||
self.state.status = .failed;
|
||||
};
|
||||
for (self.new_or_modified_files.items) |file| self.allocator.free(file.path);
|
||||
self.new_or_modified_files.clearRetainingCapacity();
|
||||
self.state.vcs_new_or_modified_files = .running;
|
||||
git.new_or_modified_files(@intFromPtr(self)) catch {
|
||||
self.state.vcs_new_or_modified_files = .failed;
|
||||
};
|
||||
} else if (try m.match(.{ tp.any, tp.any, "current_branch", tp.null_ })) {
|
||||
self.state.current_branch = .done;
|
||||
try self.loaded(parent);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue