func()

in internal/command/receivepack/receivepack.go [28:80]


func (c *Command) Execute(ctx context.Context) (context.Context, error) {
	args := c.Args.SSHArgs
	if len(args) != 2 {
		return ctx, disallowedcommand.Error
	}

	repo := args[1]
	response, err := c.verifyAccess(ctx, repo)
	if err != nil {
		return ctx, err
	}

	ctxWithLogData := context.WithValue(ctx, logData{}, command.NewLogData(
		response.Gitaly.Repo.GlProjectPath,
		response.Username,
		response.ProjectID,
		response.RootNamespaceID,
	))

	if response.IsCustomAction() {
		// When `geo_proxy_direct_to_primary` feature flag is enabled, a Git over HTTP direct request
		// to primary repo is performed instead of proxying the request through Gitlab Rails.
		// After the feature flag is enabled by default and removed,
		// custom action functionality will be removed along with it.
		if response.Payload.Data.GeoProxyDirectToPrimary {
			cmd := githttp.PushCommand{
				Config:     c.Config,
				ReadWriter: c.ReadWriter,
				Response:   response,
				Args:       c.Args,
			}

			return ctxWithLogData, cmd.Execute(ctx)
		}

		customAction := customaction.Command{
			Config:     c.Config,
			ReadWriter: c.ReadWriter,
			EOFSent:    true,
		}
		return ctxWithLogData, customAction.Execute(ctx, response)
	}

	err = c.performGitalyCall(ctx, response)
	if err != nil {
		return ctxWithLogData, err
	}

	if response.NeedAudit {
		gitauditevent.Audit(ctx, c.Args.CommandType, c.Config, response, nil /* keep nil for `git-receive-pack`*/)
	}
	return ctxWithLogData, nil
}