diff options
| author | Antoine <ajamadec@gmail.com> | 2022-09-30 19:29:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-30 19:29:03 +0200 |
| commit | a09df82861944aab86c74648b1a570ff8ff73f82 (patch) | |
| tree | dbe1ca5159fcf76f6ad3b32b43ff56e303c1cb03 /lua/telescope/builtin/__git.lua | |
| parent | 63e279049652b514b7c3cbe5f6b248db53d77516 (diff) | |
feat(git): notify when not in a git repo instead of error (#2181)
Fix #2180
Diffstat (limited to 'lua/telescope/builtin/__git.lua')
| -rw-r--r-- | lua/telescope/builtin/__git.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index 7c4f28b..acab6c4 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -392,7 +392,11 @@ local set_opts_cwd = function(opts) local in_bare = utils.get_os_command_output({ "git", "rev-parse", "--is-bare-repository" }, opts.cwd) if in_worktree[1] ~= "true" and in_bare[1] ~= "true" then - error(opts.cwd .. " is not a git directory") + utils.notify("builtin.git", { + msg = opts.cwd .. " is not a git directory", + level = "ERROR", + }) + return false elseif in_worktree[1] ~= "true" and in_bare[1] == "true" then opts.is_bare = true end @@ -401,6 +405,8 @@ local set_opts_cwd = function(opts) opts.cwd = git_root[1] end end + + return true end local function apply_checks(mod) @@ -408,8 +414,10 @@ local function apply_checks(mod) mod[k] = function(opts) opts = vim.F.if_nil(opts, {}) - set_opts_cwd(opts) - v(opts) + local ok = set_opts_cwd(opts) + if ok then + v(opts) + end end end |
