main 8d5c184

prune.go RawHistoryFolder

1package cli
2
3import (
4	"fmt"
5	"io"
6
7	"github.com/bnema/gordon/internal/adapters/dto"
8	"github.com/bnema/gordon/internal/domain"
9	"github.com/bnema/gordon/pkg/bytesize"
10)
11
12// cliRenderPruneSummary writes the shared prune verdict summary: counts
13// per verdict, what was removed, and the reasons protected or unknown
14// candidates were skipped. Dry-run and execution use the same renderer.
15func cliRenderPruneSummary(out io.Writer, summary dto.PruneSummary) error {
16	action := "Deleted"
17	if !summary.Applied {
18		action = "Would delete"
19	}
20	// The wire summary carries the authoritative counts, so the human
21	// output can never disagree with the JSON body.
22	actionCount := len(summary.Deleted)
23	if !summary.Applied {
24		actionCount = summary.Eligible
25	}
26	if err := cliWritef(out, "%s: %d (eligible=%d protected=%d unknown=%d)\n",
27		action, actionCount, summary.Eligible, summary.Protected, summary.Unknown); err != nil {
28		return err
29	}
30	if summary.ReclaimedKnown {
31		if err := cliWritef(out, "Space reclaimed: %s\n", bytesize.Format(summary.ReclaimedBytes)); err != nil {
32			return err
33		}
34	}
35	for _, failure := range summary.Failures {
36		line := fmt.Sprintf("failed to delete %s %s: %s", failure.Kind, failure.Ref, failure.Error)
37		if err := cliWriteLine(out, cliRenderWarning(line)); err != nil {
38			return err
39		}
40	}
41	for _, gap := range summary.Gaps {
42		line := fmt.Sprintf("inventory incomplete (%s: %s); dependent candidates were left untouched", gap.Source, gap.Reason)
43		if err := cliWriteLine(out, cliRenderWarning(line)); err != nil {
44			return err
45		}
46	}
47	return cliRenderSkippedCandidates(out, summary.Candidates)
48}
49
50// cliRenderSkippedCandidates lists the not-deleted candidates with their
51// first reason, so an operator can see why each resource survived.
52func cliRenderSkippedCandidates(out io.Writer, candidates []dto.PruneCandidate) error {
53	skipped := make([]dto.PruneCandidate, 0, len(candidates))
54	for _, candidate := range candidates {
55		if candidate.Verdict == string(domain.PruneVerdictEligible) {
56			continue
57		}
58		skipped = append(skipped, candidate)
59	}
60	if len(skipped) == 0 {
61		return nil
62	}
63	if err := cliWriteLine(out, cliRenderMuted("Skipped:")); err != nil {
64		return err
65	}
66	for _, candidate := range skipped {
67		reason := ""
68		if len(candidate.Reasons) > 0 {
69			reason = candidate.Reasons[0]
70		}
71		if err := cliWritef(out, "  %s %s (%s) %s\n", candidate.Kind, candidate.Ref, candidate.Verdict, reason); err != nil {
72			return err
73		}
74	}
75	return nil
76}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close