/
push.rb
19 lines (19 loc) · 1.26 KB
/
push.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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