Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ luac.out
*.x86_64
*.hex

.pre-commit-config.yaml
.luarc.json
result*
15 changes: 10 additions & 5 deletions lua/rocks-git/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,17 @@ function git.get_latest_remote_semver_tag(url)
get_latest_remote_version_tag(url, function(sc)
---@cast sc vim.SystemCompleted
if sc.code == 0 then
local latest_tag, latest_version = parser.parse_git_latest_semver_tag(sc.stdout or "")
if latest_tag and latest_version then
future.set({ latest_tag, latest_version })
else
log.warn("Could not parse latest tag from: " .. sc.stdout)
if sc.stdout == "" then
log.debug("No tag found for " .. url)
future.set({})
else
local latest_tag, latest_version = parser.parse_git_latest_semver_tag(sc.stdout)
if latest_tag and latest_version then
future.set({ latest_tag, latest_version })
else
log.warn("Could not parse latest tag from: " .. sc.stdout)
future.set({})
end
end
else
log.warn(sc.stderr)
Expand Down
9 changes: 9 additions & 0 deletions spec/git_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local git = require("rocks-git.git")
local a = require("nio").tests

local origin_pkg_dir = vim.fn.tempname()
local origin_pkg_remote_dir = vim.fs.joinpath(origin_pkg_dir, ".git", "refs", "remotes", "origin")
Expand Down Expand Up @@ -34,4 +35,12 @@ describe("git", function()
})
assert.Same("bar", head_branch)
end)

a.it("Handles a remote without semver tags", function()
local url = "https://github.com/lumen-oss/luarocks-stub.git"
local version_tuple = git.get_latest_remote_semver_tag(url).wait()
vim.print(version_tuple)
-- {} if no tag, else latest_tag, latest_version
assert.Same({}, version_tuple)
end)
end)
Loading