- Added DefaultBranch field to ListBranches_Output struct
- Computes next cursor when len(branches) == limit
- Calls gr.FindMainBranch() to populate the default branch
- Removed the two TODO comments
+16
-6
Diff
round #0
+16
-6
knotmirror/xrpc/repo_listBranches.go
+16
-6
knotmirror/xrpc/repo_listBranches.go
···
14
14
)
15
15
16
16
type ListBranches_Output struct {
17
-
Cursor *string `json:"cursor,omitempty"`
18
-
Branches []types.Branch `json:"branches"`
17
+
Cursor *string `json:"cursor,omitempty"`
18
+
DefaultBranch string `json:"defaultBranch,omitempty"`
19
+
Branches []types.Branch `json:"branches"`
19
20
}
20
21
21
22
func (x *Xrpc) ListBranches(w http.ResponseWriter, r *http.Request) {
···
73
74
return nil, fmt.Errorf("failed to get git branches: %w", err)
74
75
}
75
76
76
-
return &ListBranches_Output{
77
+
out := &ListBranches_Output{
77
78
Branches: branches,
78
-
// TODO: include default branch
79
-
// TODO: return cursor
80
-
}, nil
79
+
}
80
+
81
+
if len(branches) == limit {
82
+
nextCursor := strconv.FormatInt(cursor+int64(len(branches)), 10)
83
+
out.Cursor = &nextCursor
84
+
}
85
+
86
+
if defaultBranch, err := gr.FindMainBranch(); err == nil {
87
+
out.DefaultBranch = defaultBranch
88
+
}
89
+
90
+
return out, nil
81
91
}
82
92
83
93
func (x *Xrpc) makeRepoPath(ctx context.Context, repo syntax.ATURI) (string, error) {
History
1 round
0 comments
russ-fugal.smart-knowledge-systems.com
submitted
#0
1 commit
expand
collapse
knotmirror/xrpc: return cursor and default branch in listBranches
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Russ T Fugal <russ-fugal@smart-knowledge-systems.com>
expand 0 comments
closed without merging