gh-stack 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/lib/ui.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as p from "./output.ts";
3
3
  import pc from "picocolors";
4
4
  import type { Stack, StackMetadata } from "../types.ts";
5
- import { getOrderedBranches } from "./metadata.ts";
5
+ import { getOrderedBranches, stackBase } from "./metadata.ts";
6
6
 
7
7
  // ── Auto-yes mode (for agents/CI) ──
8
8
 
@@ -32,7 +32,10 @@ export function renderStackTree(
32
32
  const showNumbers = options?.showNumbers ?? true;
33
33
  const lines: string[] = [];
34
34
 
35
- lines.push(`${pc.green("◯")} main`);
35
+ const base = stackBase(stack);
36
+ const baseIsTrunk = base === "main" || base === "master";
37
+ const baseHint = baseIsTrunk ? "" : pc.dim(" (base — in parent stack)");
38
+ lines.push(`${pc.green("◯")} ${base}${baseHint}`);
36
39
 
37
40
  for (let i = 0; i < ordered.length; i++) {
38
41
  const branchName = ordered[i]!;
package/src/types.ts CHANGED
@@ -1,7 +1,13 @@
1
- // gh-stack metadata schema (v2)
1
+ // gh-stack metadata schema.
2
+ //
3
+ // `StackMetadata` is the in-memory shape shared by every command. Its on-disk
4
+ // representation has evolved (v1 monolith → v2 monolith → v3 per-stack files +
5
+ // git branch config), but the in-memory object stays stable so commands never
6
+ // need to know which storage version produced it. `version` reflects the
7
+ // store the object was assembled from.
2
8
 
3
9
  export interface StackMetadata {
4
- version: 2;
10
+ version: 2 | 3;
5
11
  current_stack: string | null;
6
12
  stacks: Record<string, Stack>;
7
13
  archive?: Record<string, Stack>;
@@ -12,18 +18,31 @@ export interface Stack {
12
18
  description: string;
13
19
  last_branch: string | null;
14
20
  branches: Record<string, Branch>;
21
+ // The ref this stack is rooted on. Usually the trunk ("main"), but for a
22
+ // stack that was split off another (see `gh-stack split`), this is a branch
23
+ // belonging to the parent stack. The stack's root branch is the one whose
24
+ // `parent` equals this value. Optional on disk for back-compat; treat a
25
+ // missing value as "main" via `stackBase()`.
26
+ base?: string;
15
27
  }
16
28
 
17
29
  export interface Branch {
18
30
  parent: string; // "main" or another branch name
19
31
  pr?: number; // GitHub PR number
20
32
  description?: string; // Human-readable label
33
+
34
+ // ── submit caches (v0.9.0, issue #16) ──
35
+ // Let `submit` skip redundant network calls when nothing relevant changed.
36
+ prTitle?: string; // last-known GitHub PR title, for rendering the stack viz without a fetch
37
+ prBase?: string; // last base we set on the PR via `gh pr edit --base`; skip the edit when parent is unchanged
38
+ vizHash?: string; // hash of the stack-viz block we last wrote to this PR; skip the PATCH when it would be identical
21
39
  }
22
40
 
23
41
  export interface Snapshot {
24
42
  timestamp: string; // ISO 8601
25
43
  operation: string; // "restack" | "merge" | "sync" | "remove"
26
44
  branches: Record<string, string>; // branch name -> commit SHA
45
+ stack?: string; // owning stack (v3: drives per-stack retention + file naming)
27
46
  }
28
47
 
29
48
  // Resume state for restack --resume