From 940495546ff1fe3a6bedfdd0954fff17017a23a2 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 21 Nov 2021 13:12:22 +0800 Subject: [PATCH] fix: to check path exists. lazygit -g "notExistPath" will error: *fs.PathError stat /xxxxxx/.git/: no such file or directory --- lua/lazygit.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index dca0d38..45e125f 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -165,6 +165,9 @@ local function lazygit(path) if path == nil then path = project_root_dir() end + if path == nil or not fn.isdirectory(path .. '/.git/') then + print('Not in a git repository') + end open_floating_window() local cmd = 'lazygit' if not vim.env.GIT_DIR then