fix(git): comment sign detection in get_config function (#1281)

- Modify the condition in the get_config function to correctly ignore
  comments and blank lines.
- Update the regular expression to exclude lines starting with '#' or
  ';'.
- This change ensures that only valid key-value pairs are added to the
  configuration table.
This commit is contained in:
Piotr Król 2024-01-20 15:05:26 +01:00 committed by GitHub
parent 1b3df6c007
commit d0d410bc22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -217,7 +217,7 @@ function M.get_config(repo)
current_section = section:gsub('%s+"', "."):gsub('"+%s*$', "") current_section = section:gsub('%s+"', "."):gsub('"+%s*$', "")
else else
-- Ignore comments and blank lines -- Ignore comments and blank lines
if not line:match("^%s*#") and line:match("%S") then if not line:match("^%s*[#;]") and line:match("%S") then
local key, value = line:match("^%s*(%S+)%s*=%s*(.+)%s*$") local key, value = line:match("^%s*(%S+)%s*=%s*(.+)%s*$")
ret[current_section .. "." .. key] = value ret[current_section .. "." .. key] = value
end end