From cddb4dc90e7ddbf4f2d7dc2174a86771c11511ae Mon Sep 17 00:00:00 2001 From: gbprod Date: Tue, 20 May 2025 15:07:21 +0200 Subject: [PATCH] feat: do not git if no network --- lua/phpactor/check_uptodate.lua | 9 +++++++++ lua/phpactor/handler/update.lua | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lua/phpactor/check_uptodate.lua b/lua/phpactor/check_uptodate.lua index 88432a3..8086cc8 100644 --- a/lua/phpactor/check_uptodate.lua +++ b/lua/phpactor/check_uptodate.lua @@ -8,6 +8,15 @@ return function() return false end + local network_status = os.execute("ping -c 2 8.8.8.8 > /dev/null 2>&1") + if network_status ~= 0 then + vim.notify("Network is not reachable, cannot check if Phpactor is up-to-date", vim.log.levels.ERROR, { + title = "Phpactor", + }) + + return + end + vim.fn.system({ config.options.install.git_bin, "-C", diff --git a/lua/phpactor/handler/update.lua b/lua/phpactor/handler/update.lua index 2961997..6bca46c 100644 --- a/lua/phpactor/handler/update.lua +++ b/lua/phpactor/handler/update.lua @@ -1,6 +1,15 @@ local config = require("phpactor.config") return function() + local network_status = os.execute("ping -c 2 8.8.8.8 > /dev/null 2>&1") + if network_status ~= 0 then + vim.notify("Network is not reachable, cannot update Phpactor", vim.log.levels.ERROR, { + title = "Phpactor", + }) + + return + end + local Path = require("plenary.path") local install_path = Path:new(config.options.install.path) local phpactor_path = Path:new(config.options.install.path .. "phpactor/")