mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-15 20:37:43 +00:00
Merge b75d59f18f into 3774ca20d2
This commit is contained in:
commit
086a02e835
3 changed files with 117 additions and 2 deletions
|
|
@ -468,7 +468,10 @@ def do_ini(
|
|||
# override option with no value to option with value if not allow_no_value
|
||||
if len(values) > 0:
|
||||
for index, line in enumerate(section_lines):
|
||||
if not changed_lines[index] and match_function(option, line):
|
||||
match = not changed_lines[index] and match_function(option, line)
|
||||
# skip comment-only lines (e.g. "; output_buffering" with no "="):
|
||||
# group(2) is the comment char, group(6) is "=" or "" (end-of-line match)
|
||||
if match and not (match.group(2) and not match.group(6)):
|
||||
newline = f"{option}{sep}{values.pop(0)}\n"
|
||||
(changed, msg) = update_section_line(
|
||||
option, changed, section_lines, index, changed_lines, ignore_spaces, newline, msg
|
||||
|
|
@ -477,7 +480,9 @@ def do_ini(
|
|||
break
|
||||
# remove all remaining option occurrences from the rest of the section
|
||||
for index in range(len(section_lines) - 1, 0, -1):
|
||||
if not changed_lines[index] and match_function(option, section_lines[index]):
|
||||
match = not changed_lines[index] and match_function(option, section_lines[index])
|
||||
# skip comment-only lines (no "=") — only remove active or commented config lines
|
||||
if match and not (match.group(2) and not match.group(6)):
|
||||
del section_lines[index]
|
||||
del changed_lines[index]
|
||||
changed = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue