MCPcopy Index your code
hub / github.com/rilldata/rill / GetGithubPullRequest

Method GetGithubPullRequest

cli/pkg/local/git.go:147–185  ·  view source on GitHub ↗
(ctx context.Context, r *connect.Request[localv1.GetGithubPullRequestRequest])

Source from the content-addressed store, hash-verified

145}
146
147func (s *Server) GetGithubPullRequest(ctx context.Context, r *connect.Request[localv1.GetGithubPullRequestRequest]) (*connect.Response[localv1.GetGithubPullRequestResponse], error) {
148 if !s.app.ch.IsAuthenticated() {
149 return nil, errors.New("must authenticate before performing this action")
150 }
151
152 projects, err := s.app.ch.InferProjects(ctx, s.app.ch.Org, s.app.ProjectPath)
153 if err != nil {
154 return nil, err
155 }
156 project := projects[0]
157
158 c, err := s.app.ch.Client()
159 if err != nil {
160 return nil, err
161 }
162
163 resp, err := c.GetGithubPullRequest(ctx, &adminv1.GetGithubPullRequestRequest{
164 Org: project.OrgName,
165 Project: project.Name,
166 Branch: r.Msg.Branch,
167 })
168 if err != nil {
169 return nil, err
170 }
171
172 state := localv1.GetGithubPullRequestResponse_STATE_UNSPECIFIED
173 switch resp.PrState {
174 case adminv1.GetGithubPullRequestResponse_STATE_OPEN:
175 state = localv1.GetGithubPullRequestResponse_STATE_OPEN
176 case adminv1.GetGithubPullRequestResponse_STATE_CLOSED_UNMERGED:
177 state = localv1.GetGithubPullRequestResponse_STATE_CLOSED_UNMERGED
178 case adminv1.GetGithubPullRequestResponse_STATE_MERGED:
179 state = localv1.GetGithubPullRequestResponse_STATE_MERGED
180 }
181 return connect.NewResponse(&localv1.GetGithubPullRequestResponse{
182 PrUrl: resp.PrUrl,
183 PrState: state,
184 }), nil
185}
186
187func (s *Server) GitPull(ctx context.Context, r *connect.Request[localv1.GitPullRequest]) (*connect.Response[localv1.GitPullResponse], error) {
188 // Get authenticated admin client

Callers

nothing calls this directly

Calls 4

IsAuthenticatedMethod · 0.80
InferProjectsMethod · 0.80
GetGithubPullRequestMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected