Skip to content

Commit 3e9897b

Browse files
authored
Revert "picker(git_branch): show committer, upstream and date (#695)"
This reverts commit 2e03f67.
1 parent 2e03f67 commit 3e9897b

File tree

3 files changed

+17
-71
lines changed

3 files changed

+17
-71
lines changed

lua/telescope/builtin/files.lua

+1-5
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,7 @@ files.tags = function(opts)
401401
end
402402

403403
files.current_buffer_tags = function(opts)
404-
return files.tags(vim.tbl_extend("force", {
405-
prompt_title = 'Current Buffer Tags',
406-
only_current_file = true,
407-
hide_filename = true,
408-
}, opts))
404+
return files.tags(vim.tbl_extend("force", {prompt_title = 'Current Buffer Tags', only_current_file = true, hide_filename = true}, opts))
409405
end
410406

411407
local function apply_checks(mod)

lua/telescope/builtin/git.lua

+15-65
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ local make_entry = require('telescope.make_entry')
55
local pickers = require('telescope.pickers')
66
local previewers = require('telescope.previewers')
77
local utils = require('telescope.utils')
8-
local entry_display = require('telescope.pickers.entry_display')
98

109
local conf = require('telescope.config').values
1110

@@ -78,81 +77,32 @@ git.bcommits = function(opts)
7877
end
7978

8079
git.branches = function(opts)
81-
local format = '{'
82-
.. '"head":%(if:equals=*)%(HEAD)%(then)true%(else)false%(end)'
83-
.. ',"refname":"%(refname)"'
84-
.. ',"authorname":"%(authorname)"'
85-
.. '%(if)%(upstream)%(then)'
86-
.. ',"upstream":"%(upstream:lstrip=2)"'
87-
.. '%(else)'
88-
.. ',"upstream":""'
89-
.. '%(end)'
90-
.. ',"committerdate":"%(committerdate:format-local:%Y/%m/%d %H:%M:%S)"'
91-
.. '}'
92-
local output = utils.get_os_command_output({ 'git', 'for-each-ref', '--format', format }, opts.cwd)
80+
local output = utils.get_os_command_output({ 'git', 'branch', '--all' }, opts.cwd)
9381

9482
local results = {}
95-
local widths = {
96-
name = 0,
97-
authorname = 0,
98-
upstream = 0,
99-
committerdate = 0,
100-
}
101-
local register_entry = function(entry, trim_refname_prefix)
102-
entry.name = string.sub(entry.refname, string.len(trim_refname_prefix)+1)
103-
for key, value in pairs(widths) do
104-
widths[key] = math.max(value, vim.fn.strdisplaywidth(entry[key]))
105-
end
106-
if string.len(entry.upstream) > 0 then
107-
widths.upstream_indicator = 2
108-
end
109-
table.insert(results, entry)
110-
end
11183
for _, v in ipairs(output) do
112-
local entry = vim.fn.json_decode(v)
113-
if entry.head then
114-
goto continue
115-
elseif vim.startswith(entry.refname, 'refs/remotes/') then
116-
register_entry(entry, 'refs/remotes/')
117-
elseif vim.startswith(entry.refname, 'refs/heads/') then
118-
register_entry(entry, 'refs/heads/')
84+
if not string.match(v, 'HEAD') and v ~= '' then
85+
if vim.startswith(v, '*') then
86+
table.insert(results, 1, v)
87+
else
88+
table.insert(results, v)
89+
end
11990
end
120-
::continue::
121-
end
122-
if #results == 0 then
123-
return
124-
end
125-
126-
local displayer = entry_display.create {
127-
separator = " ",
128-
items = {
129-
{ width = widths.name },
130-
{ width = widths.authorname },
131-
{ width = widths.upstream_indicator },
132-
{ width = widths.upstream },
133-
{ width = widths.committerdate },
134-
}
135-
}
136-
137-
local make_display = function(entry)
138-
return displayer {
139-
{entry.name, 'TelescopeResultsIdentifier'},
140-
{entry.authorname},
141-
{string.len(entry.upstream) > 0 and '=>' or ''},
142-
{entry.upstream, 'TelescopeResultsIdentifier'},
143-
{entry.committerdate}
144-
}
14591
end
14692

14793
pickers.new(opts, {
14894
prompt_title = 'Git Branches',
14995
finder = finders.new_table {
15096
results = results,
15197
entry_maker = function(entry)
152-
entry.value = entry.name
153-
entry.ordinal = entry.name
154-
entry.display = make_display
155-
return entry
98+
local addition = vim.startswith(entry, '*') and '* ' or ' '
99+
entry = entry:gsub('[* ] ', '')
100+
entry = entry:gsub('^remotes/', '')
101+
return {
102+
value = entry,
103+
ordinal = addition .. entry,
104+
display = addition .. entry
105+
}
156106
end
157107
},
158108
previewer = previewers.git_branch_log.new(opts),

lua/telescope/pickers/highlights.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343
function Highlighter:clear_display()
4444
if not self
4545
or not self.picker
46-
or not self.picker.results_bufnr
46+
or not self.picker.results_bufnr
4747
or not vim.api.nvim_buf_is_valid(self.picker.results_bufnr)
4848
then
4949
return

0 commit comments

Comments
 (0)