mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-11 16:00:02 -04:00
use locked revision when downloading via git
This commit is contained in:
parent
234557b95e
commit
4d2813f03b
1 changed files with 29 additions and 4 deletions
|
|
@ -125,11 +125,12 @@ function M.select_download_commands(repo, project_name, cache_folder, revision)
|
||||||
local has_curl = vim.fn.executable('curl') == 1
|
local has_curl = vim.fn.executable('curl') == 1
|
||||||
local is_github = repo.url:find("github.com", 1, true)
|
local is_github = repo.url:find("github.com", 1, true)
|
||||||
local is_gitlab = repo.url:find("gitlab.com", 1, true)
|
local is_gitlab = repo.url:find("gitlab.com", 1, true)
|
||||||
local is_windows = fn.hs('win32')
|
local is_windows = fn.has('win32') == 1
|
||||||
|
|
||||||
|
revision = revision or repo.branch or "master"
|
||||||
|
|
||||||
if has_tar and has_curl and (is_github or is_gitlab) and not is_windows then
|
if has_tar and has_curl and (is_github or is_gitlab) and not is_windows then
|
||||||
|
|
||||||
revision = revision or repo.branch or "master"
|
|
||||||
local path_sep = utils.get_path_sep()
|
local path_sep = utils.get_path_sep()
|
||||||
local url = repo.url:gsub('.git$', '')
|
local url = repo.url:gsub('.git$', '')
|
||||||
|
|
||||||
|
|
@ -172,22 +173,46 @@ function M.select_download_commands(repo, project_name, cache_folder, revision)
|
||||||
M.select_install_rm_cmd(cache_folder, project_name..'-tmp')
|
M.select_install_rm_cmd(cache_folder, project_name..'-tmp')
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
local git_folder
|
||||||
|
if is_windows then
|
||||||
|
git_folder = cache_folder ..'\\'.. project_name
|
||||||
|
else
|
||||||
|
git_folder = cache_folder ..'/'.. project_name
|
||||||
|
end
|
||||||
|
|
||||||
|
local clone_error = 'Error during download, please verify your internet connection'
|
||||||
|
if is_windows then
|
||||||
|
clone_error = clone_error .. ". If on Windows you may need to enable Developer mode"
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
cmd = 'git',
|
cmd = 'git',
|
||||||
info = 'Downloading...',
|
info = 'Downloading...',
|
||||||
err = 'Error during download, please verify your internet connection',
|
err = clone_error,
|
||||||
opts = {
|
opts = {
|
||||||
args = {
|
args = {
|
||||||
'clone',
|
'clone',
|
||||||
|
'-c', 'core.symlinks=true',
|
||||||
'--single-branch',
|
'--single-branch',
|
||||||
'--branch', repo.branch or 'master',
|
'--branch', repo.branch or 'master',
|
||||||
'--depth', '1',
|
|
||||||
repo.url,
|
repo.url,
|
||||||
project_name
|
project_name
|
||||||
},
|
},
|
||||||
cwd = cache_folder,
|
cwd = cache_folder,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cmd = 'git',
|
||||||
|
info = 'Checking out locked revision',
|
||||||
|
err = 'Error while checking out revision',
|
||||||
|
opts = {
|
||||||
|
args = {
|
||||||
|
'-c', 'core.symlinks=true',
|
||||||
|
'checkout', revision
|
||||||
|
},
|
||||||
|
cwd = git_folder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue