Skip to content

Commit b2c44dc

Browse files
committed
fix: accept legacy <ns>.<name> form on path-dep name match
Index descriptors in the current mcpp-index repo embed the namespace in the package's `[package].name` string (e.g. `name = "mcpplibs.cmdline"`) rather than using the xpkg-spec separate `namespace = "mcpplibs"; name = "cmdline"` form. Until the index is migrated, accept both: * the new short form (`name == "cmdline"`) * the legacy composite (`name == "mcpplibs.cmdline"`) Restores the self-host smoke step in CI which builds mcpp using the freshly-built mcpp; that path resolves `mcpplibs.cmdline` from the released index repo, hits the legacy descriptor, and previously failed with `mismatch with declared name 'cmdline'`.
1 parent 7902b63 commit b2c44dc

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/cli.cppm

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,14 +1334,24 @@ prepare_build(bool print_fingerprint,
13341334
}
13351335
}
13361336

1337-
// Name match: with namespaces in play we compare the dep's *short*
1338-
// name (the package's own [package].name field, which has no
1339-
// namespace prefix) against the expected short name from the
1340-
// DependencySpec. Falls back to the dep map key for old code paths
1341-
// that don't go through the namespaced parser.
1337+
// Name match: prefer the dep's *short* name (the new xpkg-style
1338+
// `[package].name = "<short>"` + separate `namespace` field), but
1339+
// fall back to the legacy composite form `<ns>.<short>` so existing
1340+
// index descriptors that still embed the namespace in the name
1341+
// string (`name = "mcpplibs.cmdline"`) keep resolving until the
1342+
// mcpp-index repo is migrated.
13421343
const std::string& expectedShort =
13431344
spec.shortName.empty() ? name : spec.shortName;
1344-
if (dep_manifest->package.name != expectedShort) {
1345+
std::string expectedComposite;
1346+
if (!spec.namespace_.empty()
1347+
&& spec.namespace_ != mcpp::manifest::kDefaultNamespace) {
1348+
expectedComposite = std::format("{}.{}", spec.namespace_, expectedShort);
1349+
}
1350+
const bool nameOk =
1351+
dep_manifest->package.name == expectedShort
1352+
|| (!expectedComposite.empty()
1353+
&& dep_manifest->package.name == expectedComposite);
1354+
if (!nameOk) {
13451355
return std::unexpected(std::format(
13461356
"dependency '{}' resolved to package '{}' (mismatch with declared name '{}')",
13471357
name, dep_manifest->package.name, expectedShort));

0 commit comments

Comments
 (0)