feat(workspace): add ListBranches method to WorkspaceService

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 18:05:18 +08:00
parent a4a6e6a01a
commit 665d029d2b
8 changed files with 68 additions and 0 deletions
+17
View File
@@ -328,6 +328,23 @@ func (s *workspaceService) GetCredentialMeta(ctx context.Context, c Caller, wsID
return cred, nil
}
func (s *workspaceService) ListBranches(ctx context.Context, c Caller, wsID uuid.UUID) ([]string, error) {
ws, err := s.repo.GetWorkspaceByID(ctx, wsID)
if err != nil {
return nil, err
}
if canRead, _, err := s.pa.ResolveByID(ctx, c.UserID, c.IsAdmin, ws.ProjectID); err != nil {
return nil, err
} else if !canRead {
return nil, errs.New(errs.CodeForbidden, "no read access")
}
cred, err := s.loadDecryptedCredential(ctx, wsID)
if err != nil {
return nil, err
}
return s.gitr.ListRemoteBranches(ctx, ws.MainPath, cred)
}
func (s *workspaceService) encryptForUpsert(wsID uuid.UUID, in UpsertCredentialInput) (*Credential, error) {
cred := &Credential{
ID: uuid.New(),