Repository navigation
Conversation
1. Root cause: packageHasInstalled used r.contains("installed") which
matches dpkg's not-installed output "package 'x' is not installed"
2. Fix: change to r.contains("Status: install ok installed") for exact
dpkg status line matching
3. Impact: dde-printer status detection in PageMultiInfo and PageSingleInfo
now correctly returns false when the package is not installed
Influence:
1. Test dde-printer detection when dde-printer is installed
2. Test dde-printer detection when dde-printer is not installed
3. Verify no regression on device manager printer menu display
fix: 修复未安装包被误判为已安装的问题
1. 根因:packageHasInstalled 使用 r.contains("installed") 模糊匹配,
dpkg 未安装包输出 "package 'x' is not installed" 同样包含该子串
2. 方案:改为 r.contains("Status: install ok installed") 精确匹配
dpkg 标准状态行
3. 影响:PageMultiInfo 和 PageSingleInfo 中 dde-printer 安装检测
在未安装时正确返回 false
Influence:
1. 测试已安装 dde-printer 时的检测结果
2. 测试未安装 dde-printer 时的检测结果
3. 验证设备管理器打印机菜单显示无回归
PMS: BUG-DEF-DM-PAGE-001
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
Reviewer's GuideCorrects false-positive package detection by matching dpkg’s exact installed status line, with stubbed parameterized tests covering installed, uninstalled, empty, and metadata-bearing outputs; this fixes dde-printer status handling used by the multi- and single-device pages. Sequence diagram for exact package installation detectionsequenceDiagram
participant PageInfo
participant QProcess
participant dpkg
PageInfo->>QProcess: start dpkg -s packageName
QProcess->>dpkg: query package status
dpkg-->>QProcess: status output
QProcess-->>PageInfo: readAll()
PageInfo->>PageInfo: packageHasInstalled(packageName)
alt output contains Status: install ok installed
PageInfo-->>PageInfo: return true
else output does not contain exact status line
PageInfo-->>PageInfo: return false
end
Flow diagram for dde-printer status handlingflowchart TD
A[PageMultiInfo or PageSingleInfo checks dde-printer] --> B[PageInfo.packageHasInstalled]
B --> C[Read dpkg status output]
C --> D{Contains exact installed status line?}
D -->|Yes| E[Report dde-printer installed]
D -->|No| F[Report dde-printer not installed]
E --> G[Show printer menu when applicable]
F --> H[Do not treat package as installed]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改,语法逻辑正确。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议在测试中增加对 QProcess::start 和 QProcess::waitForFinished 的 stub,使测试完全脱离系统环境依赖,参考下方修复代码示例。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无需修改,性能合理。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无需修改,安全合规。'] 💡 改进建议代码示例// 改进建议:在 ut_pageinfo.cpp 中增加对 QProcess::start 和 waitForFinished 的 stub,
// 使测试完全隔离系统环境依赖
static void ut_QProcess_start(void *self, const QString &program, const QStringList &arguments)
{
Q_UNUSED(self)
Q_UNUSED(program)
Q_UNUSED(arguments)
// Stub: 不实际启动进程
}
static bool ut_QProcess_waitForFinished(void *self, int msecs)
{
Q_UNUSED(self)
Q_UNUSED(msecs)
return true; // Stub: 直接返回成功
}
TEST_P(PackageHasInstalled_UT, packageHasInstalled)
{
g_readAllData = GetParam().dpkgOutput;
Stub stub;
stub.set(ADDR(QIODevice, readAll), ut_QIODevice_readAll);
stub.set(ADDR(QProcess, start), ut_QProcess_start);
stub.set(ADDR(QProcess, waitForFinished), ut_QProcess_waitForFinished);
PageMultiInfo *p = new PageMultiInfo;
PageInfo *pageInfo = dynamic_cast<PageInfo *>(p);
bool result = pageInfo->packageHasInstalled("test-package");
EXPECT_EQ(GetParam().expected, result);
delete p;
}本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.0.75 |
fix: correct packageHasInstalled false positive for uninstalled packages
matches dpkg's not-installed output "package 'x' is not installed"
dpkg status line matching
now correctly returns false when the package is not installed
Influence:
fix: 修复未安装包被误判为已安装的问题
dpkg 未安装包输出 "package 'x' is not installed" 同样包含该子串
dpkg 标准状态行
在未安装时正确返回 false
Influence:
PMS: BUG-DEF-DM-PAGE-001
Summary by Sourcery
Fix package installation status detection to accurately control printer-related device manager behavior.
Bug Fixes:
Tests:
Chores: