fix(#1970): disable git integration after 5 timeouts (#1990)

* fix(#1970): additional log function gating for efficiency when not logging

* fix(#1970): additional log function gating for efficiency when not logging

* fix(#1970): disable git integration after 10 timeouts

* fix(#1970): disable git integration after 10 timeouts

* fix(#1970): disable git integration after 10 timeouts

* fix(#1970): cleanly kill timed out git processes

* fix(#1970): revert git kill, to be completed via #1974 experiment

* fix(#1970): revert git kill, to be completed via #1974 experiment
This commit is contained in:
Alexander Courtis
2023-02-12 14:28:48 +11:00
committed by GitHub
parent b712b82b0c
commit 36e29c3a95
3 changed files with 23 additions and 0 deletions

View File

@@ -1,9 +1,13 @@
local log = require "nvim-tree.log"
local utils = require "nvim-tree.utils"
local notify = require "nvim-tree.notify"
local Runner = {}
Runner.__index = Runner
local timeouts = 0
local MAX_TIMEOUTS = 5
function Runner:_parse_status_output(status, path)
-- replacing slashes if on windows
if vim.fn.has "win32" == 1 then
@@ -159,6 +163,17 @@ function Runner.run(opts)
if self.rc == -1 then
log.line("git", "job timed out %s %s", opts.project_root, opts.path)
timeouts = timeouts + 1
if timeouts == MAX_TIMEOUTS then
notify.warn(
string.format(
"%d git jobs have timed out after %dms, disabling git integration. Try increasing git.timeout",
timeouts,
opts.timeout
)
)
require("nvim-tree.git").disable_git_integration()
end
elseif self.rc ~= 0 then
log.line("git", "job fail rc %d %s %s", self.rc, opts.project_root, opts.path)
else