GitStatus implements RuntimeService.
(ctx context.Context, req *runtimev1.GitStatusRequest)
| 89 | |
| 90 | // GitStatus implements RuntimeService. |
| 91 | func (s *Server) GitStatus(ctx context.Context, req *runtimev1.GitStatusRequest) (*runtimev1.GitStatusResponse, error) { |
| 92 | if !auth.GetClaims(ctx, req.InstanceId).Can(runtime.EditRepo) { |
| 93 | return nil, ErrForbidden |
| 94 | } |
| 95 | repo, release, err := s.runtime.Repo(ctx, req.InstanceId) |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | defer release() |
| 100 | |
| 101 | gs, err := repo.Status(ctx, req.RemoteBranch) |
| 102 | if err != nil { |
| 103 | return nil, fmt.Errorf("failed to get git status: %w", err) |
| 104 | } |
| 105 | if !gs.IsGitRepo { |
| 106 | return nil, status.Error(codes.FailedPrecondition, "not a git repository") |
| 107 | } |
| 108 | return &runtimev1.GitStatusResponse{ |
| 109 | Branch: gs.Branch, |
| 110 | GithubUrl: gs.RemoteURL, |
| 111 | Subpath: gs.Subpath, |
| 112 | ManagedGit: gs.ManagedRepo, |
| 113 | LocalChanges: gs.LocalChanges, |
| 114 | LocalCommits: gs.LocalCommits, |
| 115 | RemoteCommits: gs.RemoteCommits, |
| 116 | }, nil |
| 117 | } |
| 118 | |
| 119 | func (s *Server) ListGitCommits(ctx context.Context, req *runtimev1.ListGitCommitsRequest) (*runtimev1.ListGitCommitsResponse, error) { |
| 120 | if !auth.GetClaims(ctx, req.InstanceId).Can(runtime.EditRepo) { |