diff options
| author | Stephanie Gredell <s.raide@gmail.com> | 2026-02-22 13:32:44 -0800 |
|---|---|---|
| committer | Stephanie Gredell <s.raide@gmail.com> | 2026-02-22 13:40:34 -0800 |
| commit | 86a2e9c723945b3531f899deb2b69278457c4a2e (patch) | |
| tree | 2f59fb5ec7d42cca2861202507b17c1ff720675e | |
| parent | 603067fc728061b584299c0ced8a8eb2bf40a548 (diff) | |
| download | a4-86a2e9c723945b3531f899deb2b69278457c4a2e.tar.xz a4-86a2e9c723945b3531f899deb2b69278457c4a2e.zip | |
stuff
| -rw-r--r-- | lua/99/extensions/files/init.lua | 20 | ||||
| -rw-r--r-- | lua/99/test/files_spec.lua | 52 |
2 files changed, 62 insertions, 10 deletions
diff --git a/lua/99/extensions/files/init.lua b/lua/99/extensions/files/init.lua index 8805a12..b3c7c78 100644 --- a/lua/99/extensions/files/init.lua +++ b/lua/99/extensions/files/init.lua @@ -84,7 +84,7 @@ end --- @return _99.Files.File[] local function scan_with_git_sync(root) local cmd = string.format( - "git -C %s ls-files --cached --others --exclude-standard", + "git -C %s ls-files --cached --others --exclude-standard --deduplicate", vim.fn.shellescape(root) ) local output = vim.fn.system(cmd) @@ -106,14 +106,18 @@ local function scan_with_git_sync(root) end line = vim.trim(line) - if line ~= "" and not matches_exclude_pattern(line) then + if line ~= "" then local name = line:match("([^/]+)$") or line - table.insert(files, { - path = line, - name = name, - absolute_path = vim.fs.joinpath(root, line), - }) - count = count + 1 + if + not matches_exclude_pattern(line) and not matches_exclude_pattern(name) + then + table.insert(files, { + path = line, + name = name, + absolute_path = vim.fs.joinpath(root, line), + }) + count = count + 1 + end end end diff --git a/lua/99/test/files_spec.lua b/lua/99/test/files_spec.lua index 6c27304..53d9458 100644 --- a/lua/99/test/files_spec.lua +++ b/lua/99/test/files_spec.lua @@ -398,6 +398,55 @@ describe("files git integration", function() end end) + it( + "excludes files by filename (not just path) consistent with fs scanner", + function() + _mocks.stat_exists = true + _mocks.stat_type = "directory" + _mocks.system_output = "README.md\nsrc/builder.js\nsrc/build/config.lua\n" + _mocks.system_exit = 0 + + Files.setup({ + enabled = true, + exclude = { "build" }, + }, {}) + + local files = Files.discover_files() + + assert.are.equal(1, #files) + eq("README.md", files[1].path) + + for _, f in ipairs(files) do + assert.is_nil( + f.name:match("^build"), + "files starting with 'build' should be excluded" + ) + end + end + ) + + it("uses --deduplicate flag to handle merge conflict duplicates", function() + _mocks.stat_exists = true + _mocks.stat_type = "directory" + + _mocks.system_output = "README.md\nREADME.md\nREADME.md\n" + _mocks.system_exit = 0 + + local files = Files.discover_files() + + local has_deduplicate = false + for _, cmd in ipairs(_mocks.system_calls) do + if cmd:match("%-%-deduplicate") then + has_deduplicate = true + break + end + end + assert.is_true( + has_deduplicate, + "git command should include --deduplicate flag" + ) + end) + it("uses git-based discovery in git repo", function() _mocks.stat_exists = true _mocks.stat_type = "directory" @@ -417,8 +466,7 @@ describe("files git integration", function() end) it("falls back to filesystem when not in git repo", function() - _mocks.stat_exists = false -- .git doesn't exist - + _mocks.stat_exists = false local orig_scandir = vim.uv.fs_scandir local fs_called = false vim.uv.fs_scandir = function(_dir) |
