feat(lazygit): util.lazygit.browse can open current branch

This commit is contained in:
Iordanis Petkakis 2024-09-25 22:29:22 +03:00
parent cb40a09538
commit 6bac8ef85a

View file

@ -189,6 +189,7 @@ end
function M.browse() function M.browse()
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" }) local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
local remotes = {} ---@type {name:string, url:string}[] local remotes = {} ---@type {name:string, url:string}[]
local branch = require("lazy.manage.process").exec({ "git", "rev-parse", "--abbrev-ref", "HEAD" })[1]
for _, line in ipairs(lines) do for _, line in ipairs(lines) do
local name, remote = line:match("(%S+)%s+(%S+)%s+%(fetch%)") local name, remote = line:match("(%S+)%s+(%S+)%s+%(fetch%)")
@ -197,7 +198,7 @@ function M.browse()
if url then if url then
table.insert(remotes, { table.insert(remotes, {
name = name, name = name,
url = url, url = (branch ~= "main" and branch ~= "master") and url .. "/tree/" .. branch or url,
}) })
end end
end end