]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure we yield an empty section marker at the end of parse_ini() 2546/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 22 Mar 2024 07:47:29 +0000 (08:47 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 22 Mar 2024 07:47:29 +0000 (08:47 +0100)
Fixes #2545

mkosi/config.py
tests/test_config.py

index c2e6e2a4d64e9b6a1cca47180aec438a67d9bb05..584d00e311ba11b7740ebc6b396aced2e4966e05 100644 (file)
@@ -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(
index 51e8e602c51641f366e019c4bb326af568b6a179..dc90d6e2ce7abae6983993bf493bc70604404dd1 100644 (file)
@@ -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(