Skip to content

Commit 1e19131

Browse files
committed
(mini.deps) Update install to work on Git<2.36.0.
Details: - Option `--allow-filter-submodules` was added in 2.36.0 release. Although it was released almost two years ago, it it not a default Git version on Ubuntu 22.04, which has 2.34.1. This is usable enough OS version to make using that option conditionally.
1 parent 468a115 commit 1e19131

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

doc/mini-deps.txt

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Sources with more details:
4747
# Dependencies ~
4848

4949
For most of its functionality this plugin relies on `git` CLI tool.
50-
It should be at least version 2.36.0.
5150
See https://git-scm.com/ for more information about how to install it.
5251
Actual knowledge of Git is not required but helpful.
5352

lua/mini/deps.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
--- # Dependencies ~
4848
---
4949
--- For most of its functionality this plugin relies on `git` CLI tool.
50-
--- It should be at least version 2.36.0.
5150
--- See https://git-scm.com/ for more information about how to install it.
5251
--- Actual knowledge of Git is not required but helpful.
5352
---
@@ -891,11 +890,16 @@ H.git_args = {
891890
return { 'version' }
892891
end,
893892
clone = function(source, path)
894-
return {
893+
local res = {
895894
'clone', '--quiet', '--filter=blob:none',
896895
'--recurse-submodules', '--also-filter-submodules', '--origin', 'origin',
897896
source, path,
898897
}
898+
-- Use `--also-filter-submodules` only with appropriate version
899+
if not (H.cache.git_version.major >= 2 and H.cache.git_version.minor >= 36) then
900+
table.remove(res, 5)
901+
end
902+
return res
899903
end,
900904
stash = function(timestamp)
901905
return { 'stash', '--quiet', '--message', '(mini.deps) ' .. timestamp .. ' Stash before checkout' }

readmes/mini-deps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
### Plugin manager
88

9-
Depends on [`git`](https://git-scm.com/) CLI tool (at least version 2.36.0) being installed and callable. Make sure to have it set up.
9+
Depends on [`git`](https://git-scm.com/) CLI tool being installed and callable. Make sure to have it set up.
1010

1111
See more details in [Features](#features) and [help file](../doc/mini-deps.txt).
1212

tests/test_deps.lua

+34
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,40 @@ T['add()']['Install']['checks for executable Git'] = function()
576576
expect.error(function() add('user/new_plugin') end, 'Could not find executable `git` CLI tool')
577577
end
578578

579+
T['add()']['Install']['reacts to early Git version'] = function()
580+
child.lua([[
581+
_G.stdio_queue = {
582+
{ out = 'git version 2.35.10'}, -- Check Git executable
583+
{}, -- Clone
584+
{ out = 'sha0head' }, -- Get `HEAD`
585+
{ out = 'origin/main' }, -- Get default branch
586+
{ out = 'origin/main' }, -- Check if `main` is origin branch
587+
{ out = 'sha0head' }, -- Get commit of `origin/main`
588+
{}, -- Stash changes
589+
{}, -- Checkout changes
590+
}
591+
]])
592+
add('user/new_plugin')
593+
594+
-- Should result into a proper sequence of CLI runs
595+
--stylua: ignore
596+
local ref_git_spawn_log = {
597+
{ args = { 'version' }, cwd = child.fn.getcwd() },
598+
{
599+
'clone', '--quiet', '--filter=blob:none', '--recurse-submodules', '--origin', 'origin',
600+
'https://github.com/user/new_plugin', test_opt_dir .. '/new_plugin',
601+
},
602+
{
603+
args = { 'rev-list', '-1', 'HEAD' },
604+
cwd = test_opt_dir .. '/new_plugin',
605+
},
606+
{ 'rev-parse', '--abbrev-ref', 'origin/HEAD' },
607+
{ 'branch', '--list', '--all', '--format=%(refname:short)', 'origin/main' },
608+
{ 'rev-list', '-1', 'origin/main' },
609+
}
610+
validate_git_spawn_log(ref_git_spawn_log)
611+
end
612+
579613
T['add()']['Install']['checks out non-default target'] = function()
580614
child.lua([[
581615
_G.stdio_queue = {

0 commit comments

Comments
 (0)