From 8516627614f3d46e76afa42b4f22d40336416b0a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 22 Mar 2024 08:47:29 +0100 Subject: [PATCH] Make sure we yield an empty section marker at the end of parse_ini() Fixes #2545 --- mkosi/config.py | 3 +++ tests/test_config.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/mkosi/config.py b/mkosi/config.py index c2e6e2a4d..584d00e31 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1674,6 +1674,9 @@ def parse_ini(path: Path, only_sections: Collection[str] = ()) -> Iterator[tuple if section and setting and value is not None: yield section, setting, value + if section: + yield section, "", "" + SETTINGS = ( ConfigSetting( diff --git a/tests/test_config.py b/tests/test_config.py index 51e8e602c..dc90d6e2c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -355,6 +355,28 @@ def test_compression(tmp_path: Path) -> None: assert config.compress_output == Compression.none +def test_match_only(tmp_path: Path) -> None: + with chdir(tmp_path): + Path("mkosi.conf").write_text( + """\ + [Match] + Format=|directory + Format=|disk + """ + ) + + Path("mkosi.conf.d").mkdir() + Path("mkosi.conf.d/10-abc.conf").write_text( + """\ + [Output] + ImageId=abcde + """ + ) + + _, [config] = parse_config(["--format", "tar"]) + assert config.image_id != "abcde" + + def test_match_multiple(tmp_path: Path) -> None: with chdir(tmp_path): Path("mkosi.conf").write_text( -- 2.47.2