From 5f0ccf1346b99d6d0dab7850184f128e7926cf5f Mon Sep 17 00:00:00 2001 From: Anthony Nichols Date: Thu, 16 Sep 2021 04:58:59 -0500 Subject: [PATCH] feat: support for git-for-each-ref (git_branches) (#1248) --- doc/telescope.txt | 1 + lua/telescope/builtin/git.lua | 5 ++++- lua/telescope/builtin/init.lua | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index 9543949..36e454c 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -812,6 +812,7 @@ builtin.git_branches({opts}) *builtin.git_branches()* {cwd} (string) specify the path of the repo {use_git_root} (boolean) if we should use git root as cwd or the cwd (important for submodule) (default: true) + {pattern} (string) specify the pattern to match all refs builtin.git_status({opts}) *builtin.git_status()* diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index a4da679..0302c7d 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -195,7 +195,10 @@ git.branches = function(opts) .. "%(authorname)" .. "%(upstream:lstrip=2)" .. "%(committerdate:format-local:%Y/%m/%d %H:%M:%S)" - local output = utils.get_os_command_output({ "git", "for-each-ref", "--perl", "--format", format }, opts.cwd) + local output = utils.get_os_command_output( + { "git", "for-each-ref", "--perl", "--format", format, opts.pattern }, + opts.cwd + ) local results = {} local widths = { diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 34f0089..0a76074 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -182,6 +182,7 @@ builtin.git_bcommits = require_on_exported_call("telescope.builtin.git").bcommit ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) +---@field pattern string: specify the pattern to match all refs builtin.git_branches = require_on_exported_call("telescope.builtin.git").branches --- Lists git status for current directory