MCPcopy Create free account
hub / github.com/rilldata/rill / GitPush

Method GitPush

runtime/server/git.go:246–269  ·  view source on GitHub ↗

GitPush implements RuntimeService.

(ctx context.Context, req *runtimev1.GitPushRequest)

Source from the content-addressed store, hash-verified

244
245// GitPush implements RuntimeService.
246func (s *Server) GitPush(ctx context.Context, req *runtimev1.GitPushRequest) (*runtimev1.GitPushResponse, error) {
247 if !auth.GetClaims(ctx, req.InstanceId).Can(runtime.EditRepo) {
248 return nil, ErrForbidden
249 }
250 repo, release, err := s.runtime.Repo(ctx, req.InstanceId)
251 if err != nil {
252 return nil, err
253 }
254 defer release()
255
256 msg := req.CommitMessage
257 if msg == "" {
258 msg = "User triggered commit from Rill"
259 }
260
261 err = repo.CommitAndPush(ctx, msg, req.Force)
262 if err != nil {
263 if errors.Is(err, drivers.ErrRemoteAhead) {
264 return nil, status.Error(codes.FailedPrecondition, "remote repository has changes that are not in local state, please pull first")
265 }
266 return nil, fmt.Errorf("failed to push: %w", err)
267 }
268 return &runtimev1.GitPushResponse{}, nil
269}

Callers

nothing calls this directly

Calls 6

GetClaimsFunction · 0.92
CanMethod · 0.80
RepoMethod · 0.80
CommitAndPushMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected