openSUSE/open-build-service

View on GitHub
src/api/app/models/gitlab_payload/push.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# This class is used in TriggerControllerService::ScmExtractor to handle push events coming from Gitlab.
class GitlabPayload::Push < GitlabPayload
  def payload
    default_payload.merge(event: 'Push Hook',
                          commit_sha: webhook_payload[:after],
                          # We need this for Workflows::YAMLDownloader#download_url
                          target_branch: webhook_payload[:ref].sub('refs/heads/', ''),
                          # We need this for Workflows::YAMLDownloader#download_url
                          path_with_namespace: webhook_payload.dig(:project, :path_with_namespace),
                          # We need this for Workflow::Step#branch_request_content_github
                          source_repository_full_name: webhook_payload.dig(:project, :path_with_namespace),
                          # We need this for SCMStatusReporter#call
                          target_repository_full_name: webhook_payload.dig(:project, :path_with_namespace),
                          # We need this for SCMStatusReporter#call
                          project_id: webhook_payload[:project_id],
                          # We need this for SCMWebhookEventValidator#valid_push_event
                          ref: webhook_payload[:ref])
  end
end