From 4446fdb9af1b1c41560f6cc41452eee826a8bce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Sun, 22 Oct 2023 22:52:54 -0700 Subject: [PATCH] feat(ui): check pinned packages that can't be updated (#1139) * style: fix filter types * feat: check outdated pinned plugins --- README.md | 1 + lua/lazy/core/config.lua | 1 + lua/lazy/manage/task/git.lua | 9 ++++++++- lua/lazy/types.lua | 1 + lua/lazy/view/sections.lua | 12 ++++++++---- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9fcf781..ebcca6a 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 7ba6851..3f1f269 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 9913ea1..a1bfcf6 100644 --- a/lua/lazy/manage/task/git.lua +++ b/lua/lazy/manage/task/git.lua @@ -42,7 +42,14 @@ 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) then + if 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 + 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 222acbe..5085b14 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 0c1f578..5dfb57e 100644 --- a/lua/lazy/view/sections.lua +++ b/lua/lazy/view/sections.lua @@ -50,14 +50,12 @@ return { title = "Breaking Changes", }, { - ---@param plugin LazyPlugin filter = function(plugin) return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to end, title = "Updated", }, { - ---@param plugin LazyPlugin filter = function(plugin) return plugin._.cloned end, @@ -66,7 +64,7 @@ return { { ---@param plugin LazyPlugin filter = function(plugin) - return plugin._.updates + return plugin._.updates ~= nil end, title = "Updates", }, @@ -90,9 +88,15 @@ return { end, title = "Not Installed", }, + { + filter = function (plugin) + return plugin._.outdated + end, + title = "Outdated", + }, { filter = function(plugin) - return plugin._.loaded + return plugin._.loaded ~= nil end, title = "Loaded", },