Skip to content

Commit

Permalink
ignore comments in ignore files (#123)
Browse files Browse the repository at this point in the history
undefined
  • Loading branch information
garrett361 authored Apr 5, 2024
1 parent 515166b commit 2e30813
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/rsync/sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ local function create_filters(filter_paths)

if f ~= nil then
for line in f:lines() do
if line:sub(1, 1) == "!" then
include = include .. "--include='" .. line:sub(2, -1) .. "' "
else
exclude = exclude .. "--exclude='" .. line .. "' "
if line:sub(1, 1) ~= "#" then
if line:sub(1, 1) == "!" then
include = include .. "--include='" .. line:sub(2, -1) .. "' "
else
exclude = exclude .. "--exclude='" .. line .. "' "
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions tests/rsync/rsync_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ describe("rsync", function()
end)
end)

it("on RsyncUp with gitignore comments", function()
setup_with_gitignore(function()
-- Overwrite .gitignore w/ added comments
helpers.write_file(".gitignore", { "# Comment 1", "should_ignore.txt", "# Another comment" })
vim.cmd.RsyncUp()
helpers.wait_sync()
end)
end)

it("on RsyncUpFile", function()
setup_with_gitignore(function()
helpers.write_file("second_test.tt", { "labbal" })
Expand Down

0 comments on commit 2e30813

Please sign in to comment.