Skip to content

Commit 80bc2ed

Browse files
authored
fix(git): fix older commits and multiple remotes (#235)
1 parent 839215b commit 80bc2ed

File tree

5 files changed

+23
-227
lines changed

5 files changed

+23
-227
lines changed

lua/gitlinker/commons/json.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ M.encode = function(t)
66
if t == nil then
77
return nil
88
end
9-
return require("gitlinker.commons._json").encode(t)
9+
if vim.json ~= nil and vim.is_callable(vim.json.encode) then
10+
return vim.json.encode(t)
11+
else
12+
return require("gitlinker.commons._json").encode(t)
13+
end
1014
end
1115

1216
--- @param j string?
@@ -15,7 +19,11 @@ M.decode = function(j)
1519
if j == nil then
1620
return nil
1721
end
18-
return require("gitlinker.commons._json").decode(j)
22+
if vim.json ~= nil and vim.is_callable(vim.json.decode) then
23+
return vim.json.decode(j)
24+
else
25+
return require("gitlinker.commons._json").decode(j)
26+
end
1927
end
2028

2129
return M

lua/gitlinker/commons/ringbuf.lua

Lines changed: 0 additions & 221 deletions
This file was deleted.

lua/gitlinker/commons/uri.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ M.encode = function(value, rfc)
77
if type(value) ~= "string" then
88
return nil
99
end
10-
return require("gitlinker.commons._uri").uri_encode(value, rfc)
10+
if vim.is_callable(vim.uri_encode) then
11+
return vim.uri_encode(value, rfc)
12+
else
13+
return require("gitlinker.commons._uri").uri_encode(value, rfc)
14+
end
1115
end
1216

1317
---@param value string?
@@ -16,7 +20,11 @@ M.decode = function(value)
1620
if type(value) ~= "string" then
1721
return nil
1822
end
19-
return require("gitlinker.commons._uri").uri_decode(value)
23+
if vim.is_callable(vim.uri_decode) then
24+
return vim.uri_decode(value)
25+
else
26+
return require("gitlinker.commons._uri").uri_decode(value)
27+
end
2028
end
2129

2230
return M

lua/gitlinker/commons/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.0.0
1+
15.0.0

lua/gitlinker/git.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ local _run_cmd = async.wrap(function(args, cwd, callback)
6060
end
6161
end,
6262
}, function()
63+
logger:debug(string.format("|_run_cmd| result:%s", vim.inspect(result)))
6364
callback(result)
6465
end)
6566
end, 3)
@@ -366,7 +367,7 @@ local function get_branch_remote(cwd)
366367
return nil
367368
end
368369

369-
if #remotes == 1 then
370+
if #remotes >= 1 then
370371
return remotes[1]
371372
end
372373

0 commit comments

Comments
 (0)