3 Commits
master ... dev

Author SHA1 Message Date
5a395de735 add arbitrary tag selection with *s 2024-12-23 21:46:44 -05:00
6d6568ecfd Merge branch 'master' into dev 2024-12-23 21:42:38 -05:00
d6460d53ed notify user that this is a development version 2023-04-29 12:18:06 -04:00
2 changed files with 161 additions and 90 deletions

View File

@ -479,16 +479,23 @@ local function sync(package, cb)
return return
end end
local function log_err(err)
logger:log("error", string.format("failed to update %s; reason: %s", package.id, err))
end
proc.git_resolve_branch(package.url, package.branch, function(err, branch)
if err then
log_err(err)
cb(err)
end
package.branch = branch
if package.exists then if package.exists then
if package.pin then if package.pin then
cb() cb()
return return
end end
local function log_err(err)
logger:log("error", string.format("failed to update %s; reason: %s", package.id, err))
end
proc.git_rev_parse(package.dir, "HEAD", function(err, before) proc.git_rev_parse(package.dir, "HEAD", function(err, before)
if err then if err then
log_err(before) log_err(before)
@ -570,6 +577,7 @@ local function sync(package, cb)
cb(err) cb(err)
end) end)
end end
end)
end end
local function sync_list(list, on_complete) local function sync_list(list, on_complete)
@ -662,6 +670,7 @@ local function print_list(cb)
line = line + 1 line = line + 1
end end
print("!! Warning you are using the dev branch of dep, expect bugs")
print(string.format("Installed packages (%s):", #packages)) print(string.format("Installed packages (%s):", #packages))
indent = 1 indent = 1

View File

@ -71,4 +71,66 @@ function proc.git_checkout(dir, branch, commit, cb)
end) end)
end end
function proc.git_resolve_branch(url, branch, cb)
if string.match(branch or "", "*") ~= "*" then
cb(false, branch)
return
end
local buffer = {}
local function cb_output(_, data, _)
if data[1] ~= "" then
buffer = data
end
end
vim.fn.jobstart({
"git",
"ls-remote",
"--tags",
"--sort",
"v:refname",
url
}, {
cwd = nil,
env = { GIT_TERMINAL_PROMPT = 0 },
stdin = nil,
on_stdout = cb_output,
on_stderr = cb_output,
on_exit = function(_, exit_code, _)
if exit_code == 0 then
-- get a list of all versions
local versions = {}
for _, v in pairs(buffer) do
local s, e = string.find(v, "refs/tags/.+")
if not s or not e then
goto continue
end
local tag = string.sub(v, s, e)
tag = string.gsub(tag, "refs/tags/", "")
tag = string.gsub(tag, "%^{}", "")
table.insert(versions, tag)
::continue::
end
-- match the chosen version against all versions
for i = #versions, 1, -1 do
if branch == "*" then
cb(false, versions[i])
return
else
local r = string.match(versions[i], branch)
if r then
cb(false, r)
return
end
end
end
end
end
})
end
return proc return proc