aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/managers
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-01 15:02:43 +0200
committerGitHub <noreply@github.com>2022-05-01 15:02:43 +0200
commit52d8f78fd1c1657f58115adc1928763571ffc7fa (patch)
tree0eb4ab1657980b7fc425c75d3d1920e5a345d545 /lua/nvim-lsp-installer/core/managers
parentfeat: allow excluding servers from automatic installation (#643) (diff)
downloadmason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar.gz
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar.bz2
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar.lz
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar.xz
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.tar.zst
mason-52d8f78fd1c1657f58115adc1928763571ffc7fa.zip
feat(receipt): add "github_release" type (#650)
This is for sources that uses GitHub releases, but doesn't target a specific asset file (as opposed to the github_release_file source).
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers')
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/init.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua
index cb19ad2e..107bc94d 100644
--- a/lua/nvim-lsp-installer/core/managers/github/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/github/init.lua
@@ -2,6 +2,7 @@ local installer = require "nvim-lsp-installer.core.installer"
local std = require "nvim-lsp-installer.core.managers.std"
local client = require "nvim-lsp-installer.core.managers.github.client"
local platform = require "nvim-lsp-installer.platform"
+local Result = require "nvim-lsp-installer.core.result"
local M = {}
@@ -84,4 +85,48 @@ function M.gunzip_release_file(opts)
return release_file_source
end
+---@async
+---@param receipt InstallReceipt
+function M.check_outdated_primary_package_release(receipt)
+ local source = receipt.primary_source
+ if source.type ~= "github_release" and source.type ~= "github_release_file" then
+ return Result.failure "Receipt does not have a primary source of type (github_release|github_release_file)."
+ end
+ return client.fetch_latest_release(source.repo, { tag_name_pattern = source.tag_name_pattern }):map_catching(
+ ---@param latest_release GitHubRelease
+ function(latest_release)
+ if source.release ~= latest_release.tag_name then
+ return {
+ name = source.repo,
+ current_version = source.release,
+ latest_version = latest_release.tag_name,
+ }
+ end
+ error "Primary package is not outdated."
+ end
+ )
+end
+
+---@async
+---@param receipt InstallReceipt
+function M.check_outdated_primary_package_tag(receipt)
+ local source = receipt.primary_source
+ if source.type ~= "github_tag" then
+ return Result.failure "Receipt does not have a primary source of type github_tag."
+ end
+ return client.fetch_latest_tag(source.repo):map_catching(
+ ---@param latest_tag GitHubTag
+ function(latest_tag)
+ if source.tag ~= latest_tag.name then
+ return {
+ name = source.repo,
+ current_version = source.tag,
+ latest_version = latest_tag.name,
+ }
+ end
+ error "Primary package is not outdated."
+ end
+ )
+end
+
return M