From e08a5b13312495fe6534b0c9b89cc0ffe06b7079 Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Fri, 15 Jan 2021 09:27:46 +0100 Subject: feat: show git log for remote branches (#428) --- lua/telescope/builtin/git.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lua/telescope/builtin/git.lua') diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index c2d31c6..c30625e 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -28,8 +28,7 @@ git.files = function(opts) end git.commits = function(opts) - local cmd = 'git log --pretty=oneline --abbrev-commit' - local results = vim.split(utils.get_os_command_output(cmd), '\n') + local results = utils.get_os_command_output({ 'git', 'log', '--pretty=oneline', '--abbrev-commit' }) pickers.new(opts, { prompt_title = 'Git Commits', @@ -47,8 +46,9 @@ git.commits = function(opts) end git.bcommits = function(opts) - local cmd = 'git log --pretty=oneline --abbrev-commit ' .. vim.fn.expand('%') - local results = vim.split(utils.get_os_command_output(cmd), '\n') + local results = utils.get_os_command_output({ + 'git', 'log', '--pretty=oneline', '--abbrev-commit', vim.fn.expand('%') + }) pickers.new(opts, { prompt_title = 'Git BCommits', @@ -68,7 +68,7 @@ end git.branches = function(opts) -- Does this command in lua (hopefully): -- 'git branch --all | grep -v HEAD | sed "s/.* //;s#remotes/[^/]*/##" | sort -u' - local output = vim.split(utils.get_os_command_output('git branch --all'), '\n') + local output = utils.get_os_command_output({ 'git', 'branch', '--all' }) local tmp_results = {} for _, v in ipairs(output) do @@ -106,9 +106,9 @@ git.branches = function(opts) end git.status = function(opts) - local output = utils.get_os_command_output('git status -s') + local output = utils.get_os_command_output{ 'git', 'status', '-s' } - if output == '' then + if table.getn(output) == 0 then print('No changes found') return end @@ -116,7 +116,7 @@ git.status = function(opts) pickers.new(opts, { prompt_title = 'Git Status', finder = finders.new_table { - results = vim.split(output, '\n'), + results = output, entry_maker = make_entry.gen_from_git_status(opts) }, previewer = previewers.git_file_diff.new(opts), -- cgit v1.2.3