feat(git): submodule recursion on by default
This commit is contained in:
@@ -249,7 +249,7 @@ function Repo.new(gitdir, worktree)
|
|||||||
util.debounce(Repo._fetch_status, 50)
|
util.debounce(Repo._fetch_status, 50)
|
||||||
self:start_watcher()
|
self:start_watcher()
|
||||||
self:refresh()
|
self:refresh()
|
||||||
if vim.g.git_submodule_recursion then
|
if vim.g.git_submodule_recursion ~= false then
|
||||||
self:_start_modules_watcher()
|
self:_start_modules_watcher()
|
||||||
for _, name in ipairs(find_submodules(gitdir)) do
|
for _, name in ipairs(find_submodules(gitdir)) do
|
||||||
self:_register_submodule(name)
|
self:_register_submodule(name)
|
||||||
@@ -382,7 +382,7 @@ function Repo:_handle_fs_event(relpath)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self:_invalidate(relpath)
|
self:_invalidate(relpath)
|
||||||
if relpath == "modules" and vim.g.git_submodule_recursion then
|
if relpath == "modules" and vim.g.git_submodule_recursion ~= false then
|
||||||
if vim.uv.fs_stat(vim.fs.joinpath(self.gitdir, "modules")) then
|
if vim.uv.fs_stat(vim.fs.joinpath(self.gitdir, "modules")) then
|
||||||
self:_start_modules_watcher()
|
self:_start_modules_watcher()
|
||||||
for _, name in ipairs(find_submodules(self.gitdir)) do
|
for _, name in ipairs(find_submodules(self.gitdir)) do
|
||||||
|
|||||||
+8
-16
@@ -218,21 +218,13 @@ t.test("refresh emits change.paths listing structurally-changed paths", function
|
|||||||
t.falsy(change.paths["b"], "b is unchanged structurally")
|
t.falsy(change.paths["b"], "b is unchanged structurally")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
t.test("submodule: parent enumerates initialized submodules with flag on", function()
|
t.test("submodule: parent enumerates initialized submodules by default", function()
|
||||||
vim.g.git_submodule_recursion = true
|
|
||||||
t.defer(function()
|
|
||||||
vim.g.git_submodule_recursion = nil
|
|
||||||
end)
|
|
||||||
local outer_path = h.make_submodule_repo()
|
local outer_path = h.make_submodule_repo()
|
||||||
local outer = assert(require("git.core.repo").resolve(outer_path))
|
local outer = assert(require("git.core.repo").resolve(outer_path))
|
||||||
t.truthy(outer._submodules["sub"], "sub recorded as submodule")
|
t.truthy(outer._submodules["sub"], "sub recorded as submodule")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
t.test("submodule: recursion flag eagerly creates child Repos and subscribes", function()
|
t.test("submodule: eagerly creates child Repos and subscribes by default", function()
|
||||||
vim.g.git_submodule_recursion = true
|
|
||||||
t.defer(function()
|
|
||||||
vim.g.git_submodule_recursion = nil
|
|
||||||
end)
|
|
||||||
local outer_path = h.make_submodule_repo()
|
local outer_path = h.make_submodule_repo()
|
||||||
local outer = assert(require("git.core.repo").resolve(outer_path))
|
local outer = assert(require("git.core.repo").resolve(outer_path))
|
||||||
wait_initial(outer)
|
wait_initial(outer)
|
||||||
@@ -257,23 +249,23 @@ t.test("submodule: recursion flag eagerly creates child Repos and subscribes", f
|
|||||||
t.eq(entry.kind, "changed")
|
t.eq(entry.kind, "changed")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
t.test("submodule: no eager creation when flag is off", function()
|
t.test("submodule: no eager creation when flag is explicitly disabled", function()
|
||||||
|
vim.g.git_submodule_recursion = false
|
||||||
|
t.defer(function()
|
||||||
|
vim.g.git_submodule_recursion = nil
|
||||||
|
end)
|
||||||
local outer_path = h.make_submodule_repo()
|
local outer_path = h.make_submodule_repo()
|
||||||
local outer = assert(require("git.core.repo").resolve(outer_path))
|
local outer = assert(require("git.core.repo").resolve(outer_path))
|
||||||
wait_initial(outer)
|
wait_initial(outer)
|
||||||
t.eq(
|
t.eq(
|
||||||
require("git.core.repo").all()[outer_path .. "/sub"],
|
require("git.core.repo").all()[outer_path .. "/sub"],
|
||||||
nil,
|
nil,
|
||||||
"inner Repo not created when flag off"
|
"inner Repo not created when flag is false"
|
||||||
)
|
)
|
||||||
t.eq(next(outer._submodules), nil)
|
t.eq(next(outer._submodules), nil)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
t.test("submodule: outer created after inner picks up existing child", function()
|
t.test("submodule: outer created after inner picks up existing child", function()
|
||||||
vim.g.git_submodule_recursion = true
|
|
||||||
t.defer(function()
|
|
||||||
vim.g.git_submodule_recursion = nil
|
|
||||||
end)
|
|
||||||
local outer_path = h.make_submodule_repo()
|
local outer_path = h.make_submodule_repo()
|
||||||
local inner = assert(
|
local inner = assert(
|
||||||
require("git.core.repo").resolve(outer_path .. "/sub")
|
require("git.core.repo").resolve(outer_path .. "/sub")
|
||||||
|
|||||||
Reference in New Issue
Block a user