diff options
| author | William Boman <william@redwill.se> | 2023-03-14 00:59:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-14 00:59:56 +0100 |
| commit | 63988d84311defc54a36d8befcb8df3646ac1cbc (patch) | |
| tree | 49cabad159798e91eeeb08a8dad872cf9569cc92 /lua | |
| parent | chore: autogenerate (#1093) (diff) | |
| download | mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar.gz mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar.bz2 mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar.lz mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar.xz mason-63988d84311defc54a36d8befcb8df3646ac1cbc.tar.zst mason-63988d84311defc54a36d8befcb8df3646ac1cbc.zip | |
fix(sources): also set .desc property when updating spec (#1095)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/package/init.lua | 2 | ||||
| -rw-r--r-- | lua/mason-registry/sources/github.lua | 13 | ||||
| -rw-r--r-- | lua/mason-registry/sources/init.lua | 2 | ||||
| -rw-r--r-- | lua/mason-registry/sources/lua.lua | 1 |
4 files changed, 13 insertions, 5 deletions
diff --git a/lua/mason-core/package/init.lua b/lua/mason-core/package/init.lua index e9c8e26f..e64c491e 100644 --- a/lua/mason-core/package/init.lua +++ b/lua/mason-core/package/init.lua @@ -90,8 +90,6 @@ function Package.new(spec) bin = { spec.bin, { "t", "nil" } }, share = { spec.share, { "t", "nil" } }, } - -- XXX: this is for compatibilty with the PackageSpec structure - spec.desc = spec.description else vim.validate { name = { spec.name, "s" }, diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua index 63ddba29..636e8840 100644 --- a/lua/mason-registry/sources/github.lua +++ b/lua/mason-registry/sources/github.lua @@ -36,6 +36,7 @@ GitHubRegistrySource.__index = GitHubRegistrySource function GitHubRegistrySource.new(spec) local root_dir = path.concat { path.registry_prefix(), "github", spec.namespace, spec.name } return setmetatable({ + id = spec.id, spec = spec, root_dir = root_dir, data_file = path.concat { root_dir, "registry.json" }, @@ -70,6 +71,9 @@ function GitHubRegistrySource:reload() local _ = Pkg.Lang[lang] end, spec.languages) + -- XXX: this is for compatibilty with the PackageSpec structure + spec.desc = spec.description + local pkg = self.buffer and self.buffer[spec.name] if pkg then -- Apply spec to the existing Package instance. This is important as to not have lingering package @@ -105,13 +109,18 @@ end ---@async function GitHubRegistrySource:install() return Result.try(function(try) + local version = self.spec.version + if self:is_installed() and version ~= nil then + -- Fixed version - nothing to update + return + end + if not fs.async.dir_exists(self.root_dir) then log.debug("Creating registry directory", self) try(Result.pcall(fs.async.mkdirp, self.root_dir)) end - local version = self.spec.version - if version == nil or version == "latest" then + if version == nil then log.trace("Resolving latest version for registry", self) ---@type GitHubRelease local release = try(providers.github.get_latest_release(self.spec.repo)) diff --git a/lua/mason-registry/sources/init.lua b/lua/mason-registry/sources/init.lua index 5a332326..0e5e0d29 100644 --- a/lua/mason-registry/sources/init.lua +++ b/lua/mason-registry/sources/init.lua @@ -17,7 +17,7 @@ local function parse(registry_id) repo = ("%s/%s"):format(namespace, name), namespace = namespace, name = name, - version = version or "latest", + version = version, } end elseif type == "lua" then diff --git a/lua/mason-registry/sources/lua.lua b/lua/mason-registry/sources/lua.lua index ac41c03c..e78bda4c 100644 --- a/lua/mason-registry/sources/lua.lua +++ b/lua/mason-registry/sources/lua.lua @@ -10,6 +10,7 @@ LuaRegistrySource.__index = LuaRegistrySource ---@param spec LuaRegistrySourceSpec function LuaRegistrySource.new(spec) return setmetatable({ + id = spec.id, spec = spec, }, LuaRegistrySource) end |
