diff options
| author | William Boman <william@redwill.se> | 2022-05-19 00:07:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-19 00:07:50 +0200 |
| commit | ec532c36eeed36ded785696727a85a9a00f71f22 (patch) | |
| tree | 69d7b97b34ab873fdf3c55b60b43c399f27b35ab /lua/nvim-lsp-installer/core/managers/github | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar.gz mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar.bz2 mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar.lz mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar.xz mason-ec532c36eeed36ded785696727a85a9a00f71f22.tar.zst mason-ec532c36eeed36ded785696727a85a9a00f71f22.zip | |
fix(erlangls): follow git tags (#708)
Closes #683.
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers/github')
| -rw-r--r-- | lua/nvim-lsp-installer/core/managers/github/init.lua | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua index 58856b66..b3721705 100644 --- a/lua/nvim-lsp-installer/core/managers/github/init.lua +++ b/lua/nvim-lsp-installer/core/managers/github/init.lua @@ -3,6 +3,7 @@ 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.core.platform" local Result = require "nvim-lsp-installer.core.result" +local _ = require "nvim-lsp-installer.core.functional" local M = {} @@ -21,15 +22,26 @@ local function with_release_file_receipt(repo, asset_file, release) end end +---@param repo string +---@param tag string +local function with_tag_receipt(repo, tag) + return function() + local ctx = installer.context() + ctx.receipt:with_primary_source { + type = "github_tag", + repo = repo, + tag = tag, + } + end +end + ---@async ---@param opts {repo: string, version: Optional|nil, asset_file: string|fun(release: string):string} function M.release_file(opts) local ctx = installer.context() - local release = (opts.version or ctx.requested_version):or_else_get(function() + local release = _.coalesce(opts.version, ctx.requested_version):or_else_get(function() return client.fetch_latest_release(opts.repo) - :map(function(release) - return release.tag_name - end) + :map(_.prop "tag_name") :get_or_throw "Failed to fetch latest release from GitHub API." end) ---@type string @@ -56,6 +68,22 @@ function M.release_file(opts) } end +---@async +---@param opts {repo: string, version: Optional|nil} +function M.tag(opts) + local ctx = installer.context() + local tag = _.coalesce(opts.version, ctx.requested_version):or_else_get(function() + return client.fetch_latest_tag(opts.repo) + :map(_.prop "name") + :get_or_throw "Failed to fetch latest tag from GitHub API." + end) + + return { + tag = tag, + with_receipt = with_tag_receipt(opts.repo, tag), + } +end + ---@param filename string ---@param processor async fun() local function release_file_processor(filename, processor) |
