~tomleb/repo-url.nvim

731f7aed054f7d775154c528d1a46f9ed008916d — Tom Lebreux 6 months ago 3c7de94
Fix error if Origin.Ref not exist
1 files changed, 6 insertions(+), 4 deletions(-)

M lua/repo-url/init.lua
M lua/repo-url/init.lua => lua/repo-url/init.lua +6 -4
@@ 148,14 148,16 @@ local function go_modcache_info(filename)
    return false
  end

  if json.Origin.VCS ~= 'git' then
  if not json.Origin or json.Origin.VCS ~= 'git' then
    return false
  end

  local commit = json.Origin.Hash
  local match, _, tag = string.find(json.Origin.Ref, 'refs/tags/([^/]+)')
  if match then
    commit = tag
  if json.Origin.Ref ~= nil then
    local match, _, tag = string.find(json.Origin.Ref, 'refs/tags/([^/]+)')
    if match then
      commit = tag
    end
  end

  local hostname = json.Origin.URL:match '://([^/]+)/'