@@ -13,14 +13,30 @@ const (
1313 stackFileName = "gh-stack"
1414)
1515
16- // BranchRef represents a branch and its HEAD commit.
16+ // PullRequestRef holds relatively immutable metadata about an associated PR.
17+ type PullRequestRef struct {
18+ Number int `json:"number"`
19+ ID string `json:"id,omitempty"`
20+ URL string `json:"url,omitempty"`
21+ Title string `json:"title,omitempty"`
22+ }
23+
24+ // BranchRef represents a branch and its associated commit hash.
25+ // For the trunk, Head stores the HEAD commit SHA.
26+ // For stacked branches, Base stores the merge-base commit SHA
27+ // (the last common commit before divergence from the parent branch).
1728type BranchRef struct {
18- Branch string `json:"branch"`
19- Head string `json:"head"`
29+ Branch string `json:"branch"`
30+ Head string `json:"head,omitempty"`
31+ Base string `json:"base,omitempty"`
32+ PullRequest * PullRequestRef `json:"pullRequest,omitempty"`
2033}
2134
2235// Stack represents a single stack of branches.
2336type Stack struct {
37+ ID string `json:"id,omitempty"`
38+ State string `json:"state,omitempty"`
39+ Open bool `json:"open,omitempty"`
2440 Trunk BranchRef `json:"trunk"`
2541 Branches []BranchRef `json:"branches"`
2642}
@@ -144,6 +160,7 @@ func Load(gitDir string) (*StackFile, error) {
144160 if err := json .Unmarshal (data , & sf ); err != nil {
145161 return nil , fmt .Errorf ("parsing stack file: %w" , err )
146162 }
163+
147164 return & sf , nil
148165}
149166
0 commit comments