diff options
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers/git')
| -rw-r--r-- | lua/nvim-lsp-installer/core/managers/git/init.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/git/init.lua b/lua/nvim-lsp-installer/core/managers/git/init.lua index bdd79917..f3c6ee65 100644 --- a/lua/nvim-lsp-installer/core/managers/git/init.lua +++ b/lua/nvim-lsp-installer/core/managers/git/init.lua @@ -1,23 +1,34 @@ local spawn = require "nvim-lsp-installer.core.spawn" local Result = require "nvim-lsp-installer.core.result" +local installer = require "nvim-lsp-installer.core.installer" + local M = {} ----@param opts {[1]:string} @The first item in the table is the repository to clone. -function M.clone(opts) - ---@async - ---@param ctx InstallContext - return function(ctx) - local repo = assert(opts[1], "No git URL provided.") - ctx.spawn.git { "clone", "--depth", "1", repo, "." } - ctx.requested_version:if_present(function(version) - ctx.spawn.git { "fetch", "--depth", "1", "origin", version } - ctx.spawn.git { "checkout", "FETCH_HEAD" } - end) +---@param repo string +local function with_receipt(repo) + return function() + local ctx = installer.context() ctx.receipt:with_primary_source(ctx.receipt.git_remote(repo)) end end ---@async +---@param opts {[1]:string} @The first item in the table is the repository to clone. +function M.clone(opts) + local ctx = installer.context() + local repo = assert(opts[1], "No git URL provided.") + ctx.spawn.git { "clone", "--depth", "1", repo, "." } + ctx.requested_version:if_present(function(version) + ctx.spawn.git { "fetch", "--depth", "1", "origin", version } + ctx.spawn.git { "checkout", "FETCH_HEAD" } + end) + + return { + with_receipt = with_receipt(repo), + } +end + +---@async ---@param receipt InstallReceipt ---@param install_dir string function M.check_outdated_git_clone(receipt, install_dir) |
