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

Method GitPull

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

Source from the content-addressed store, hash-verified

185}
186
187func (s *Server) GitPull(ctx context.Context, r *connect.Request[localv1.GitPullRequest]) (*connect.Response[localv1.GitPullResponse], error) {
188 // Get authenticated admin client
189 if !s.app.ch.IsAuthenticated() {
190 return nil, errors.New("must authenticate before performing this action")
191 }
192
193 projects, err := s.app.ch.InferProjects(ctx, s.app.ch.Org, s.app.ProjectPath)
194 if err != nil {
195 if !errors.Is(err, cmdutil.ErrInferProjectFailed) {
196 return nil, err
197 }
198 return nil, errors.New("repo is not connected to a project")
199 }
200 project := projects[0]
201
202 gitPath, subpath, err := gitutil.InferRepoRootAndSubpath(s.app.ProjectPath)
203 if err != nil {
204 // Not a git repo
205 return nil, connect.NewError(connect.CodeFailedPrecondition, err)
206 }
207 if project.Subpath != subpath {
208 return nil, errors.New("detected subpath within git repo does not match project subpath")
209 }
210
211 config, err := s.app.ch.GitHelper(s.app.ch.Org, project.Name, gitPath).GitConfig(ctx)
212 if err != nil {
213 return nil, err
214 }
215 err = gitutil.SetRemote(gitPath, config)
216 if err != nil {
217 return nil, err
218 }
219
220 remote, err := config.FullyQualifiedRemote()
221 if err != nil {
222 return nil, err
223 }
224
225 out, err := gitutil.RunGitPull(ctx, gitPath, r.Msg.DiscardLocal, remote, config.RemoteName())
226 if err != nil {
227 return nil, err
228 }
229 return connect.NewResponse(&localv1.GitPullResponse{
230 Output: out,
231 }), nil
232}
233
234func (s *Server) GitPush(ctx context.Context, r *connect.Request[localv1.GitPushRequest]) (*connect.Response[localv1.GitPushResponse], error) {
235 // Get authenticated admin client

Callers

nothing calls this directly

Calls 9

InferRepoRootAndSubpathFunction · 0.92
SetRemoteFunction · 0.92
RunGitPullFunction · 0.92
IsAuthenticatedMethod · 0.80
InferProjectsMethod · 0.80
GitConfigMethod · 0.80
GitHelperMethod · 0.80
FullyQualifiedRemoteMethod · 0.80
RemoteNameMethod · 0.80

Tested by

no test coverage detected