From 9437ab08c5ff9388d607e37a6252bfcc1645c353 Mon Sep 17 00:00:00 2001 From: Masahiro Kasashima Date: Thu, 25 May 2023 22:12:16 +0900 Subject: [PATCH] Added hash mark uri encoding for branch name --- lua/openingh/utils.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lua/openingh/utils.lua b/lua/openingh/utils.lua index 68a4557..132ed14 100644 --- a/lua/openingh/utils.lua +++ b/lua/openingh/utils.lua @@ -77,17 +77,21 @@ end -- Returns the current branch or commit if they are available on remote -- otherwise this will return the default branch of the repo function M.get_current_branch_or_commit() - local current_branch = get_current_branch() - if current_branch ~= "HEAD" and M.is_branch_upstreamed(current_branch) then - return current_branch + local core = function() + local current_branch = get_current_branch() + if current_branch ~= "HEAD" and M.is_branch_upstreamed(current_branch) then + return current_branch + end + + local commit_hash = get_current_commit_hash() + if current_branch == "HEAD" and M.is_commit_upstreamed(commit_hash) then + return commit_hash + end + + return M.get_default_branch() end - local commit_hash = get_current_commit_hash() - if current_branch == "HEAD" and M.is_commit_upstreamed(commit_hash) then - return commit_hash - end - - return M.get_default_branch() + return string.gsub(core(), "#", "%%23") end -- get the active buf relative file path form the .git