mirror of https://github.com/folke/lazy.nvim.git
fix(git): properly compare git commits with short refs
This commit is contained in:
parent
3ad6d95a30
commit
dc9c92a9b3
|
@ -22,7 +22,7 @@ function M.fast_check(opts)
|
|||
plugin._.updates = nil
|
||||
local info = Git.info(plugin.dir)
|
||||
local ok, target = pcall(Git.get_target, plugin)
|
||||
if ok and info and target and info.commit ~= target.commit then
|
||||
if ok and info and target and not Git.eq(info, target) then
|
||||
plugin._.updates = { from = info, to = target }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,14 @@ function M.info(repo, details)
|
|||
end
|
||||
end
|
||||
|
||||
---@param a GitInfo
|
||||
---@param b GitInfo
|
||||
function M.eq(a, b)
|
||||
local ra = a.commit and a.commit:sub(1, 7)
|
||||
local rb = b.commit and b.commit:sub(1, 7)
|
||||
return ra == rb
|
||||
end
|
||||
|
||||
function M.head(repo)
|
||||
return Util.head(repo .. "/.git/HEAD")
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ M.log = {
|
|||
error("no target commit found")
|
||||
end
|
||||
assert(target.commit, self.plugin.name .. " " .. target.branch)
|
||||
if target.commit ~= info.commit then
|
||||
if not Git.eq(info, target) then
|
||||
self.plugin._.updates = { from = info, to = target }
|
||||
end
|
||||
table.insert(args, info.commit .. ".." .. target.commit)
|
||||
|
@ -165,7 +165,7 @@ M.checkout = {
|
|||
|
||||
-- dont run checkout if target is already reached.
|
||||
-- unless we just cloned, since then we won't have any data yet
|
||||
if info.commit == target.commit and info.branch == target.branch then
|
||||
if Git.eq(info, target) and info.branch == target.branch then
|
||||
self.plugin._.updated = {
|
||||
from = info.commit,
|
||||
to = info.commit,
|
||||
|
|
Loading…
Reference in New Issue