Skip to content

Commit a09da6a

Browse files
authored
fix(cargo): don't attempt to fetch versions when version targets commit SHA (#1585)
1 parent 41e75af commit a09da6a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lua/mason-core/installer/registry/providers/cargo.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ end
6060
function M.get_versions(purl)
6161
---@type string?
6262
local repository_url = _.path({ "qualifiers", "repository_url" }, purl)
63+
local rev = _.path({ "qualifiers", "rev" }, purl)
6364
if repository_url then
65+
if rev == "true" then
66+
-- When ?rev=true we're targeting a commit SHA. It's not feasible to retrieve all commit SHAs for a
67+
-- repository so we fail instead.
68+
return Result.failure "Unable to retrieve commit SHAs."
69+
end
70+
6471
---@type Result?
6572
local git_tags = _.cond {
6673
{

tests/mason-core/installer/registry/providers/cargo_spec.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,16 @@ describe("cargo provider :: versions", function()
136136
assert.spy(providers.github.get_all_tags).was_called(1)
137137
assert.spy(providers.github.get_all_tags).was_called_with "rust-lang/rust-analyzer"
138138
end)
139+
140+
it("should not provide git commit SHAs", function()
141+
local result = cargo.get_versions(purl {
142+
qualifiers = {
143+
repository_url = "https://github.com/rust-lang/rust-analyzer",
144+
rev = "true",
145+
},
146+
})
147+
148+
assert.is_false(result:is_success())
149+
assert.equals("Unable to retrieve commit SHAs.", result:err_or_nil())
150+
end)
139151
end)

0 commit comments

Comments
 (0)