6016e2b06f60
fix back error message for no older generation (OF-8) — back() now checks for any generation older than current; if none, prints ':: error: already at the oldest generation' and exits cleanly instead of running rollback and surfacing nixos-rebuild's 'build failed'; prev now resolves to newest-older gen, not current-1 — build+tests green
- time
- 2026-06-05 02:19 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- nina finishing brief
- parent
- ab2b04787858
↓ nina-6016e2b0.tar.gzatlas at this save
files changed2 files
src/commands.zig+15 −1src/output.zig+7 −0src/commands.zig+15 −1
@@ -80,7 +80,21 @@8080 8181 var current: u32 = 0;8282 for (gens) |g| if (g.current) { current = g.number; };83- const prev = if (current > 1) current - 1 else current;83+84+ // Newest generation older than current. If there is none, we're already at the85+ // oldest — stop cleanly instead of letting rollback fail with 'build failed'.86+ var prev: u32 = 0;87+ var has_prev = false;88+ for (gens) |g| {89+ if (g.number < current and (!has_prev or g.number > prev)) {90+ prev = g.number;91+ has_prev = true;92+ }93+ }94+ if (!has_prev) {95+ output.alreadyOldest();96+ return;97+ }8498 8599 output.backStart(ctx.machine.name, current, prev);86100 if (ctx.cfg.confirm and !output.confirm("")) return;src/output.zig+7 −0
@@ -223,6 +223,13 @@223223 p("{s}done gen {s}{d}{s}\n", .{ hdr(), c(BOLD), n, c(RESET) });224224 }225225 226+// `back` has nothing older to roll back to. This is a clean stop, not a build227+// failure — the rollback would otherwise surface nixos-rebuild's confusing228+// 'no profile version older than the current' as a fake build error.229+pub fn alreadyOldest() void {230+ p("{s}already at the oldest generation\n", .{if (color_enabled) ERR_C else ERR_P});231+}232+226233 // Like generationDone but for `back` specifically — a successful rollback earns227234 // the gentle kaomoji. `go` keeps the plain generationDone line.228235 pub fn backDone(n: u32) void {