Skip to content

Commit

Permalink
fix(default_branch): use real-time remote (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
linrongbin16 authored Nov 28, 2023
1 parent b20b740 commit 15b0d41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lua/gitlinker/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,11 @@ local function get_branch_remote()
return nil
end

--- @param remote string
--- @return string?
local function get_default_branch()
local args = { "git", "rev-parse", "--abbrev-ref", "origin/HEAD" }
local function get_default_branch(remote)
local args =
{ "git", "rev-parse", "--abbrev-ref", string.format("%s/HEAD", remote) }
local result = cmd(args)
if type(result.stdout) ~= "table" or #result.stdout == 0 then
return nil
Expand Down
2 changes: 1 addition & 1 deletion lua/gitlinker/linker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ local function make_linker()
-- vim.inspect(buf_path_on_cwd)
-- )

local default_branch = git.get_default_branch()
local default_branch = git.get_default_branch(remote)
local current_branch = git.get_current_branch()

local o = {
Expand Down

0 comments on commit 15b0d41

Please sign in to comment.