Fix Repo Mirror List Filtering and Sorting · Entire
Review: PR #1665 — repo mirror list: add --repo filter and --sort
Overview
Adds two client-side presentation controls to entire repo mirror list:
--repo <substr>— case-insensitive substring filter on repo name (fills the gap where the control plane filters owner/provider/cluster but not repo name). Applies to table,--json, and--show-available.--sort <column>— sort by displayed column header,-prefix = descending.- New deterministic default order: owner/repo asc, cluster-host tiebreak.
Backed by shared helpers (sortMirrors, sortAvailable, filterByRepo, parseSortColumn). +431/-19, two files, tests only + command file.
Correctness — solid
parseSortColumnvalidates against the column list, errors name valid columns. Only lowercased known values reach theswitch, sodefault= repo tiebreak is safe.filterByReporeturnsmake([]T, 0, len)on non-empty substr → non-nil empty slice →[]in JSON, notnull. Test pins this. Good.- Empty
--sort→ first column (repo) → both mirrors and available get deterministic default order. Correct. descreverses the full comparator (tiebreak included); documented and tested.- Tie/nil edge cases fine (
SortStableFuncon nil ok;mirrorColumnsconst non-empty).
Test coverage is thorough — dup-repo cluster tiebreak, non-repo column fallback, whitespace-spec parsing, unknown-column errors, --json, --show-available, direct helper unit tests. Strong.
Issues
Low — invalid --sort fetches all pages before erroring. sortMirrors/sortAvailable run inside the runCoreList fetch closure, after fetchAllPages walks every page and after the stderr banner prints. A typo'd --sort nope does a full network round-trip only to fail on a value knowable up front. Validate the spec in PreRunE (or before fetchAllPages) to fail fast.
// repo_mirror.go — parseSortColumn is pure; call it before the fetch
Nit — misleading mirrorColumns doc comment. New wording: "where --repo and a bare cluster/provider substring still match". filterByRepo matches m.Repo only — a cluster/provider substring does not match via --repo. Reads like --repo searches the clone URL. Reword or drop.
Nit — stale execMirrorList comment. Says "exercise --json and the client-side --filter/--sort" — flag is --repo, not --filter.
Nit — --repo help discoverability. "Filter by repo name" doesn't say substring or case-insensitive, unlike the good --sort help. Consider "Filter by repo-name substring (case-insensitive)".
Conventions / security / perf
- Follows repo patterns (agent-safe: plain text +
--json, no TTY gating). ✓ - No API/auth/data changes; pure client-side post-fetch shaping. Low risk. ✓
- Perf negligible (in-memory filter/sort of already-fetched list). ✓
- Tests use isolated seam,
t.Parallel()where safe (correctly omitted where seam swapped). ✓
Verdict
Approve after the nits. Only substantive item is the fast-fail on bad --sort (low). Nothing blocking correctness.