From 63cf2a52bd46019914fc41160c9601db06fdd469 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 29 Nov 2022 08:23:23 +0100 Subject: [PATCH] feat: added "Lazy check" to check for updates without updating --- README.md | 4 ++-- lua/lazy/manage/init.lua | 14 ++++++++++++++ lua/lazy/manage/task/git.lua | 8 ++++++-- lua/lazy/view/commands.lua | 3 +++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8750a36..fb3e782 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ - [x] Config in multiple files - [x] Patterns for local packages - [x] Profiling -- [ ] lockfile -- [ ] check for updates +- [x] lockfile +- [x] check for updates - [ ] package.lua - [ ] package-lock.lua - [x] tag/version support `git tag --sort version:refname` diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua index eb7fd50..b272c07 100644 --- a/lua/lazy/manage/init.lua +++ b/lua/lazy/manage/init.lua @@ -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({ diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua index b2f8ceb..71f73a3 100644 --- a/lua/lazy/manage/task/git.lua +++ b/lua/lazy/manage/task/git.lua @@ -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 diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua index 0a9c037..bfc2deb 100644 --- a/lua/lazy/view/commands.lua +++ b/lua/lazy/view/commands.lua @@ -40,6 +40,9 @@ M.commands = { update = function() Manage.update({ clear = true, interactive = true }) end, + check = function() + Manage.check({ clear = true, interactive = true }) + end, restore = function() Manage.update({ clear = true, interactive = true, lockfile = true }) end,