fix(layout): handle submodule sections whose name differs from path
ci/woodpecker/push/eco Pipeline was successful

The duplicate-settings guard compared the section field dict with a set
and could raise TypeError instead of reporting the real configuration
error. Compare sets and add a fixture accepting a section name that
differs from its path.
This commit is contained in:
cflmy committed 2026-11-26 17:28:13 +08:00
1 parent f08ec00dec
commit 7aac052149
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -285,7 +285,7 @@ def check_submodules(config, active, depth, label, urls):
for name, fields in sections.items():
require(set(fields) == {"path", "url"},
f"{label}: unexpected submodule settings: "
f"{sorted(f'submodule.{name}.{field}' for field in fields ^ {'path', 'url'})}")
f"{sorted(f'submodule.{name}.{field}' for field in set(fields) ^ {'path', 'url'})}")
path = fields["path"]
require(path not in by_path, f"{label}: duplicate submodule path: {path}")
by_path[path] = fields["url"]
+9
View File
@@ -658,6 +658,15 @@ release = "optional"
with self.assertRaisesRegex(ValueError, "invalid submodule URL: cli"):
layout.validate("HEAD", False)
def test_accepts_a_submodule_section_name_that_differs_from_its_path(self):
self.root_repo(CLI, {"cli": "a" * 40}, {"cli": CORE_URL})
self.write(self.root, ".gitmodules",
f'[submodule "core-runtime"]\n\tpath = cli\n\turl = {CORE_URL}\n')
self.stage(self.root)
self.gitlink(self.root, "cli", "a" * 40)
self.git("commit", "-qm", "named section")
layout.validate("HEAD", False)
def test_rejects_a_wrong_domain_root_url(self):
self.root_repo(CLI + WEB_DOMAIN,
{"cli": "a" * 40, "extensions/web": "b" * 40},