mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 12:50:09 -04:00
feat: support alternative git host with different archive structure
Some git hosting services name the directory inside their tarball archive differently. For example codeberg, unlike github, does not add the revision suffix to the direcotry in the tarball.
This commit is contained in:
parent
7aa24acae3
commit
81d5366fb7
1 changed files with 21 additions and 1 deletions
|
|
@ -261,7 +261,27 @@ local function do_download(logger, url, project_name, cache_dir, revision, outpu
|
|||
do -- Move tmp dir to output dir
|
||||
local dir_rev = revision:find('^v%d') and revision:sub(2) or revision
|
||||
local repo_project_name = url:match('[^/]-$')
|
||||
local extracted = fs.joinpath(tmp, repo_project_name .. '-' .. dir_rev)
|
||||
|
||||
---@type string?
|
||||
local extracted = nil
|
||||
local candidates = {
|
||||
fs.joinpath(tmp, repo_project_name .. '-' .. dir_rev),
|
||||
fs.joinpath(tmp, repo_project_name),
|
||||
}
|
||||
|
||||
for i, path in ipairs(candidates) do
|
||||
if uv.fs_lstat(path) then
|
||||
extracted = path
|
||||
break
|
||||
elseif i < #candidates then
|
||||
logger:debug('Could not find extracted dir %s, trying %s...', path, candidates[i + 1])
|
||||
end
|
||||
end
|
||||
|
||||
if not extracted then
|
||||
return logger:error('Could not find extracted dir')
|
||||
end
|
||||
|
||||
logger:debug('Moving %s to %s/...', extracted, output_dir)
|
||||
local err = uv_rename(extracted, output_dir)
|
||||
a.schedule()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue