Skip to content

fix(cli): stop upgrade list column widths growing with item count - #2121

Open
chennaji9 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/upgrade-list-column-width
Open

chennaji9 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/upgrade-list-column-width

Conversation

@chennaji9

Copy link
Copy Markdown

What does this PR do?

CLIPrinter::printUpgradeList computed its column widths with the padding added inside the per-item loop:

std::for_each(list.cbegin(), list.cend(), [&idLen, &installedLen](const auto &info) {
    idLen = std::max(idLen, info.id.size()) + 2;
    installedLen = std::max(installedLen, info.oldVersion.size()) + 2;
});

The + 2 column padding accumulates once per package: 100 packages whose ids are all 14 characters produce a 214-character ID column instead of 16. The upgrade table bloats with the number of upgradable apps, wraps in normal terminals, and the column position depends on the item count.

Compute the maxima inside the loop and apply the padding once afterwards.

Validation

  • New unit test CLIPrinter.PrintUpgradeListColumnWidthIndependentOfItemCount: 100 entries with identical 14-char ids and a single-entry list both place oldVersion at offset 16 (id.size() + 2); on the old code the 100-entry offset would be 214, so the test fails without the fix.
  • All 20 CLIPrinter tests pass with the change: ctest -R CLIPrinter → 20/20 Passed (including the pre-existing PrintUpgradeList and PrintUpgradeListEmpty).
  • Full ll-tests target builds cleanly.

🤖 Generated with Claude Code

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @chennaji9. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/linglong/src/linglong/cli/cli_printer.cpp 44.44% <100.00%> (+0.41%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

printUpgradeList added the +2 column padding inside the per-item loop, so
each extra package widened the ID and Installed columns by 2 regardless of
content (100 identical 14-char ids produced a 214-char column); compute
the maxima in the loop and add the padding once afterwards; add a unit
test asserting the column offset is independent of the item count.

Signed-off-by: 陈那几 <2078634206@qq.com>
@chennaji9
chennaji9 force-pushed the fix/upgrade-list-column-width branch from 3a32862 to f2251d0 Compare October 13, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants