From 0c2666d28a529c4f02b69ef9a67b41bcada9c6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Wed, 18 Oct 2023 17:02:18 -0700 Subject: [PATCH] feat: check outdated pinned plugins --- README.md | 1 + lua/lazy/core/config.lua | 1 + lua/lazy/manage/task/git.lua | 7 ++++++- lua/lazy/types.lua | 1 + lua/lazy/view/sections.lua | 6 ++++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fcf781fa..ebcca6ac8 100644 --- a/README.md +++ b/README.md @@ -409,6 +409,7 @@ return { concurrency = nil, ---@type number? set to 1 to check for updates very slowly notify = true, -- get a notification when new updates are found frequency = 3600, -- check for updates every hour + check_pinned = false, -- check for pinned packages that can't be updated }, change_detection = { -- automatically check for config file changes and reload the ui diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 7ba6851dd..3f1f26918 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -119,6 +119,7 @@ M.defaults = { concurrency = nil, ---@type number? set to 1 to check for updates very slowly notify = true, -- get a notification when new updates are found frequency = 3600, -- check for updates every hour + check_pinned = false, -- check for pinned packages that can't be updated }, change_detection = { -- automatically check for config file changes and reload the ui diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua index 9913ea10f..48196e7d0 100644 --- a/lua/lazy/manage/task/git.lua +++ b/lua/lazy/manage/task/git.lua @@ -42,7 +42,12 @@ M.log = { error("no target commit found") end assert(target.commit, self.plugin.name .. " " .. target.branch) - if not Git.eq(info, target) then + if Git.eq(info, target) and Config.options.checker.check_pinned then + local last_commit = Git.get_commit(self.plugin.dir, target.branch, true) + if not Git.eq(info, { commit = last_commit }) then + self.plugin._.outdated = true + end + else self.plugin._.updates = { from = info, to = target } end table.insert(args, info.commit .. ".." .. target.commit) diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua index 222acbea7..5085b14ea 100644 --- a/lua/lazy/types.lua +++ b/lua/lazy/types.lua @@ -14,6 +14,7 @@ ---@field is_local? boolean ---@field updates? {from:GitInfo, to:GitInfo} ---@field cloned? boolean +---@field outdated? boolean ---@field kind? LazyPluginKind ---@field dep? boolean True if this plugin is only in the spec as a dependency ---@field cond? boolean diff --git a/lua/lazy/view/sections.lua b/lua/lazy/view/sections.lua index f34a740da..5dfb57e98 100644 --- a/lua/lazy/view/sections.lua +++ b/lua/lazy/view/sections.lua @@ -88,6 +88,12 @@ return { end, title = "Not Installed", }, + { + filter = function (plugin) + return plugin._.outdated + end, + title = "Outdated", + }, { filter = function(plugin) return plugin._.loaded ~= nil