mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 03:24:13 +00:00
fix(git): mark local plugins as needing updates only if local is behind upstream
This commit is contained in:
parent
c771cf4928
commit
29aae56bc1
2 changed files with 24 additions and 10 deletions
|
@ -35,7 +35,9 @@ end
|
||||||
function M.fast_check(opts)
|
function M.fast_check(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
if not plugin.pin and not plugin.dev and plugin._.installed then
|
-- don't check local plugins here, since we mark them as needing updates
|
||||||
|
-- only if local is behind upstream (if the git log task gives no output)
|
||||||
|
if plugin._.installed and not (plugin.pin or plugin._.is_local) then
|
||||||
plugin._.updates = nil
|
plugin._.updates = nil
|
||||||
local info = Git.info(plugin.dir)
|
local info = Git.info(plugin.dir)
|
||||||
local ok, target = pcall(Git.get_target, plugin)
|
local ok, target = pcall(Git.get_target, plugin)
|
||||||
|
|
|
@ -32,11 +32,13 @@ M.log = {
|
||||||
"--no-show-signature",
|
"--no-show-signature",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local info, target
|
||||||
|
|
||||||
if opts.updated then
|
if opts.updated then
|
||||||
table.insert(args, self.plugin._.updated.from .. ".." .. (self.plugin._.updated.to or "HEAD"))
|
table.insert(args, self.plugin._.updated.from .. ".." .. (self.plugin._.updated.to or "HEAD"))
|
||||||
elseif opts.check then
|
elseif opts.check then
|
||||||
local info = assert(Git.info(self.plugin.dir))
|
info = assert(Git.info(self.plugin.dir))
|
||||||
local target = assert(self.plugin._.is_local and Git.get_local_target(self.plugin) or Git.get_target(self.plugin))
|
target = assert(self.plugin._.is_local and Git.get_local_target(self.plugin) or Git.get_target(self.plugin))
|
||||||
if not target.commit then
|
if not target.commit then
|
||||||
for k, v in pairs(target) do
|
for k, v in pairs(target) do
|
||||||
error(k .. " '" .. v .. "' not found")
|
error(k .. " '" .. v .. "' not found")
|
||||||
|
@ -44,15 +46,17 @@ M.log = {
|
||||||
error("no target commit found")
|
error("no target commit found")
|
||||||
end
|
end
|
||||||
assert(target.commit, self.plugin.name .. " " .. target.branch)
|
assert(target.commit, self.plugin.name .. " " .. target.branch)
|
||||||
if Git.eq(info, target) then
|
if not self.plugin._.is_local then
|
||||||
if Config.options.checker.check_pinned then
|
if Git.eq(info, target) then
|
||||||
local last_commit = Git.get_commit(self.plugin.dir, target.branch, true)
|
if Config.options.checker.check_pinned then
|
||||||
if not Git.eq(info, { commit = last_commit }) then
|
local last_commit = Git.get_commit(self.plugin.dir, target.branch, true)
|
||||||
self.plugin._.outdated = true
|
if not Git.eq(info, { commit = last_commit }) then
|
||||||
|
self.plugin._.outdated = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
self.plugin._.updates = { from = info, to = target }
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.plugin._.updates = { from = info, to = target }
|
|
||||||
end
|
end
|
||||||
table.insert(args, info.commit .. ".." .. target.commit)
|
table.insert(args, info.commit .. ".." .. target.commit)
|
||||||
else
|
else
|
||||||
|
@ -63,6 +67,14 @@ M.log = {
|
||||||
args = args,
|
args = args,
|
||||||
cwd = self.plugin.dir,
|
cwd = self.plugin.dir,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- for local plugins, mark as needing updates only if local is
|
||||||
|
-- behind upstream, i.e. if git log gave no output
|
||||||
|
if opts.check and self.plugin._.is_local then
|
||||||
|
if not vim.tbl_isempty(self:get_log()) then
|
||||||
|
self.plugin._.updates = { from = info, to = target }
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue