mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat: added "Lazy check" to check for updates without updating
This commit is contained in:
parent
d486bc586b
commit
63cf2a52bd
4 changed files with 25 additions and 4 deletions
|
@ -83,6 +83,20 @@ function M.update(opts)
|
|||
end)
|
||||
end
|
||||
|
||||
function M.check(opts)
|
||||
opts = opts or {}
|
||||
M.run({
|
||||
pipeline = {
|
||||
"git.fetch",
|
||||
"wait",
|
||||
{ "git.log", check = true },
|
||||
},
|
||||
plugins = function(plugin)
|
||||
return plugin.uri and plugin._.installed
|
||||
end,
|
||||
}, opts)
|
||||
end
|
||||
|
||||
---@param opts? ManagerOpts
|
||||
function M.log(opts)
|
||||
M.run({
|
||||
|
|
|
@ -6,14 +6,14 @@ local Lock = require("lazy.manage.lock")
|
|||
local M = {}
|
||||
|
||||
M.log = {
|
||||
---@param opts {since?: string, updated?:boolean}
|
||||
---@param opts {since?: string, updated?:boolean, check?: boolean}
|
||||
skip = function(plugin, opts)
|
||||
if opts.updated and not (plugin._.updated and plugin._.updated.from ~= plugin._.updated.to) then
|
||||
return true
|
||||
end
|
||||
return not Util.file_exists(plugin.dir .. "/.git")
|
||||
end,
|
||||
---@param opts {since?: string, updated?:boolean}
|
||||
---@param opts {since?: string, updated?:boolean, check?:boolean}
|
||||
run = function(self, opts)
|
||||
local args = {
|
||||
"log",
|
||||
|
@ -26,6 +26,10 @@ M.log = {
|
|||
|
||||
if opts.updated then
|
||||
table.insert(args, self.plugin._.updated.from .. ".." .. (self.plugin._.updated.to or "HEAD"))
|
||||
elseif opts.check then
|
||||
local info = assert(Git.info(self.plugin.dir))
|
||||
local target = assert(Git.get_target(self.plugin))
|
||||
table.insert(args, info.commit .. ".." .. target.commit)
|
||||
else
|
||||
table.insert(args, "--since=" .. (opts.since or "7 days ago"))
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue