mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
Merge pull request #277 from pockata/faster-branch-name
Use fugitive for faster branch name resolution
This commit is contained in:
commit
3476228be2
@ -11,14 +11,25 @@ function M.project_key()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.branch_key()
|
function M.branch_key()
|
||||||
-- `git branch --show-current` requires Git v2.22.0+ so going with more
|
local branch
|
||||||
-- widely available command
|
|
||||||
local branch = M.get_os_command_output({
|
-- use tpope's fugitive for faster branch name resolution if available
|
||||||
"git",
|
if vim.fn.exists("*FugitiveHead") == 1 then
|
||||||
"rev-parse",
|
branch = vim.fn["FugitiveHead"]()
|
||||||
"--abbrev-ref",
|
-- return "HEAD" for parity with `git rev-parse` in detached head state
|
||||||
"HEAD",
|
if #branch == 0 then
|
||||||
})[1]
|
branch = "HEAD"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- `git branch --show-current` requires Git v2.22.0+ so going with more
|
||||||
|
-- widely available command
|
||||||
|
branch = M.get_os_command_output({
|
||||||
|
"git",
|
||||||
|
"rev-parse",
|
||||||
|
"--abbrev-ref",
|
||||||
|
"HEAD",
|
||||||
|
})[1]
|
||||||
|
end
|
||||||
|
|
||||||
if branch then
|
if branch then
|
||||||
return vim.loop.cwd() .. "-" .. branch
|
return vim.loop.cwd() .. "-" .. branch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user