fix: resolve extension definitions from config#1671
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors extension resolution in RunContext::resolve by matching extension layers against target layer definitions, and removes verbose logging in Cli::run. The review identifies a prefix matching bug and an unnecessary shouldEnable check in the matching logic. It suggests finding the best (longest or exact) matching definition directly, which would also allow the removal of the helper function isExtensionBelongTo.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
If a matching definition is found, use its metadata directly. Fall back to manual construction only when no match exists.
deepin pr auto review我来审查这段代码的改动,并从语法逻辑、代码质量、性能和安全性几个方面提出改进建议。 语法逻辑
代码质量
性能
安全性
具体改进建议
static utils::error::Result<api::types::v1::ExtensionDefine> findMatchingExtension(
const RuntimeLayer& extLayer,
const RuntimeLayer& targetLayer) {
// 实现查找逻辑
}
// 可以在循环外创建扩展工厂实例
auto extFactory = extension::ExtensionFactory::getInstance();
for (const auto &def : *targetInfo.extensions) {
if (extFactory->shouldEnable(def.name) && def.name == extLayer.getReference().id) {
return &def;
}
}
auto manualDefs = makeManualExtensionDefine({ extensionRefStr });
if (!manualDefs) {
return LINGLONG_ERR("Failed to create manual extension define: {}",
manualDefs.error().message());
}
if (extLayer.getReference().id.empty()) {
return LINGLONG_ERR("Extension ID is empty");
}
if (!targetInfo.extensions) {
return LINGLONG_ERR("Target layer has no extensions defined");
}
LogI("Searching for extension {} in target layer {}",
extLayer.getReference().toString(),
targetLayer->get().getReference().toString());这些改进建议可以提高代码的可维护性、性能和安全性,同时保持原有功能的完整性。 |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors extension resolution in RunContext::resolve to dynamically match extension definitions from the target layer, falling back to manual definitions with a warning log if not found. It also removes redundant debug logging in cli.cpp and adds a warning log when getExtensionInfo fails in resolveLayer. The review feedback recommends adding a null check for the ext pointer returned by ExtensionFactory::makeExtension to prevent potential null pointer dereferences.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengbo11, reddevillg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
If a matching definition is found, use its metadata directly. Fall back to manual construction only when no match exists.