Skip to content

Commit

Permalink
feat(checker): only report an update once and do a fast update check …
Browse files Browse the repository at this point in the history
…after each manage operation
  • Loading branch information
folke committed Dec 13, 2022
1 parent f24c055 commit 2a7466a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ M.defaults = {
checker = {
-- lazy can automatically check for updates
enabled = false,
concurrency = 10, -- set to 1 to very slowly check for updates
concurrency = nil, ---@type number? set to 1 to very slowly check for updates
notify = true, -- get a notification if new updates are found
frequency = 3600, -- every hour
},
Expand Down
10 changes: 8 additions & 2 deletions lua/lazy/manage/checker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local M = {}

M.running = false
M.updated = {}
M.reported = {}

function M.start()
M.fast_check()
Expand All @@ -15,6 +16,7 @@ end

function M.fast_check()
for _, plugin in pairs(Config.plugins) do
plugin._.has_updates = nil
local info = Git.info(plugin.dir)
local target = Git.get_target(plugin)
if info and target and info.commit ~= target.commit then
Expand All @@ -36,10 +38,14 @@ end

function M.report()
local lines = {}
M.updated = {}
for _, plugin in pairs(Config.plugins) do
if plugin._.has_updates and not vim.tbl_contains(M.updated, plugin.name) then
table.insert(lines, "- **" .. plugin.name .. "**")
if plugin._.has_updates then
table.insert(M.updated, plugin.name)
if not vim.tbl_contains(M.reported, plugin.name) then
table.insert(lines, "- **" .. plugin.name .. "**")
table.insert(M.reported, plugin.name)
end
end
end
if #lines > 0 and Config.options.checker.notify then
Expand Down
1 change: 1 addition & 0 deletions lua/lazy/manage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function M.run(ropts, opts)
runner:wait(function()
vim.cmd([[do User LazyRender]])
Plugin.update_state()
require("lazy.manage.checker").fast_check()
end)

if opts.wait then
Expand Down

0 comments on commit 2a7466a

Please sign in to comment.