fix: relative paths with '-' breaking git

relative paths with '-' inside a `string.match` statement were not
matching properly due to the nature of lua matching patterns. Replacing
'-' with '%-' resolves the issue.
This commit is contained in:
kiyan42 2020-04-23 21:03:18 +02:00
parent f906cb0195
commit 7fbcfa531c

View File

@ -30,15 +30,16 @@ end
local function is_folder_dirty(relpath) local function is_folder_dirty(relpath)
for _, status in pairs(GIT_STATUS) do for _, status in pairs(GIT_STATUS) do
if string.match(status, relpath) ~= nil then return true end local match_path = relpath:gsub('(%-)', '%%-')
if string.match(status, match_path) ~= nil then return true end
end end
end end
local function create_git_checker(pattern) local function create_git_checker(pattern)
return function(relpath) return function(relpath)
for _, status in pairs(GIT_STATUS) do for _, status in pairs(GIT_STATUS) do
-- TODO: fix .* as it could be problematic local match_path = relpath:gsub('(%-)', '%%-')
local ret = string.match(status, '^.. .*' .. relpath) local ret = string.match(status, '^.. .*' .. match_path)
if ret ~= nil and string.match(ret, pattern) ~= nil then return true end if ret ~= nil and string.match(ret, pattern) ~= nil then return true end
end end
return false return false