summaryrefslogtreecommitdiff
path: root/lua/telescope/builtin/git.lua
diff options
context:
space:
mode:
authortami5 <kkharji@protonmail.com>2022-03-13 20:11:27 +0300
committerGitHub <noreply@github.com>2022-03-13 18:11:27 +0100
commitef7b6ada6d91a1b2932492d78c730e4fc00cd2ea (patch)
treedda4cb7cb3357724c83e85666bc8dc5c1ee2e898 /lua/telescope/builtin/git.lua
parent75b57304323861631519e204d9fbca7bdbf1c4c5 (diff)
feat: improve UX with vim.notify (#1763)
* fix(notify): don't report request on new line * ref(notify): update message format * ref(msgs): always quote values + decrease duplication * fix(ci): undefined variables * ref(actions): temporary silent actions.__index errors * cleanup * revert: panic effort, we continue to use error for those Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
Diffstat (limited to 'lua/telescope/builtin/git.lua')
-rw-r--r--lua/telescope/builtin/git.lua26
1 files changed, 21 insertions, 5 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua
index af5d4c6..2683107 100644
--- a/lua/telescope/builtin/git.lua
+++ b/lua/telescope/builtin/git.lua
@@ -15,13 +15,21 @@ local git = {}
git.files = function(opts)
if opts.is_bare then
- error "This operation must be run in a work tree"
+ utils.notify("builtin.git_files", {
+ msg = "This operation must be run in a work tree",
+ level = "ERROR",
+ })
+ return
end
local show_untracked = utils.get_default(opts.show_untracked, true)
local recurse_submodules = utils.get_default(opts.recurse_submodules, false)
if show_untracked and recurse_submodules then
- error "Git does not support both --others and --recurse-submodules"
+ utils.notify("builtin.git_files", {
+ msg = "Git does not support both --others and --recurse-submodules",
+ level = "ERROR",
+ })
+ return
end
-- By creating the entry maker after the cwd options,
@@ -300,7 +308,11 @@ end
git.status = function(opts)
if opts.is_bare then
- error "This operation must be run in a work tree"
+ utils.notify("builtin.git_status", {
+ msg = "This operation must be run in a work tree",
+ level = "ERROR",
+ })
+ return
end
local gen_new_finder = function()
@@ -308,13 +320,17 @@ git.status = function(opts)
local git_cmd = { "git", "status", "-s", "--", "." }
if expand_dir then
- table.insert(git_cmd, table.getn(git_cmd) - 1, "-u")
+ table.insert(git_cmd, #git_cmd - 1, "-u")
end
local output = utils.get_os_command_output(git_cmd, opts.cwd)
- if table.getn(output) == 0 then
+ if #output == 0 then
print "No changes found"
+ utils.notify("builtin.git_status", {
+ msg = "No changes found",
+ level = "WARN",
+ })
return
end