Skip to content

Commit 25ff8a1

Browse files
committed
schema for storage format
1 parent fdaa11f commit 25ff8a1

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

internal/stack/schema.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "gh-stack file",
4+
"description": "Schema for the .git/gh-stack file that stores the state of all stacks in a repository.",
5+
"type": "object",
6+
"required": ["schemaVersion", "stacks"],
7+
"properties": {
8+
"schemaVersion": {
9+
"type": "integer",
10+
"const": 1,
11+
"description": "Schema version for forward compatibility."
12+
},
13+
"repository": {
14+
"type": "string",
15+
"description": "The owner/name slug of the repository (e.g. 'github/gh-stack')."
16+
},
17+
"stacks": {
18+
"type": "array",
19+
"description": "All stacks tracked in this repository.",
20+
"items": { "$ref": "#/$defs/stack" }
21+
}
22+
},
23+
"$defs": {
24+
"stack": {
25+
"type": "object",
26+
"description": "A single stack of branches.",
27+
"required": ["trunk", "branches"],
28+
"properties": {
29+
"id": {
30+
"type": "string",
31+
"description": "Identifier for this stack, populated from the API when available."
32+
},
33+
"state": {
34+
"type": "string",
35+
"description": "State of the stack from the API (e.g. 'open', 'merged')."
36+
},
37+
"open": {
38+
"type": "boolean",
39+
"description": "Whether the stack is open or closed."
40+
},
41+
"trunk": {
42+
"$ref": "#/$defs/branchRef",
43+
"description": "The trunk (base) branch of the stack."
44+
},
45+
"branches": {
46+
"type": "array",
47+
"description": "Ordered list of branches in the stack, from bottom to top.",
48+
"items": { "$ref": "#/$defs/branchRef" }
49+
}
50+
}
51+
},
52+
"branchRef": {
53+
"type": "object",
54+
"description": "A reference to a branch and its associated commit hash. For the trunk, 'head' stores the HEAD commit. For stacked branches, 'base' stores the merge-base commit (the last common commit before divergence from the parent branch).",
55+
"required": ["branch"],
56+
"properties": {
57+
"branch": {
58+
"type": "string",
59+
"description": "The branch name."
60+
},
61+
"head": {
62+
"type": "string",
63+
"description": "The HEAD commit SHA of this branch. Used for the trunk branch."
64+
},
65+
"base": {
66+
"type": "string",
67+
"description": "The merge-base commit SHA — the last commit before this branch diverged from its parent. Used for stacked branches."
68+
},
69+
"pullRequest": {
70+
"$ref": "#/$defs/pullRequestRef",
71+
"description": "Associated pull request information, if a PR exists for this branch."
72+
}
73+
}
74+
},
75+
"pullRequestRef": {
76+
"type": "object",
77+
"description": "A snapshot of relatively immutable pull request metadata.",
78+
"required": ["number"],
79+
"properties": {
80+
"number": {
81+
"type": "integer",
82+
"description": "The PR number."
83+
},
84+
"id": {
85+
"type": "string",
86+
"description": "The PR node ID (GraphQL ID)."
87+
},
88+
"url": {
89+
"type": "string",
90+
"format": "uri",
91+
"description": "Direct URL to the pull request."
92+
},
93+
"title": {
94+
"type": "string",
95+
"description": "The PR title at the time it was recorded."
96+
}
97+
}
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)