Commit a4eabca0 authored by James Lopez's avatar James Lopez

Merge branch 'fix-external-pull-request-id' into 'master'

Use Pull Request number instead of ID

See merge request gitlab-org/gitlab-ee!16504
parents 3fd1d417 0f972ef9
......@@ -20,8 +20,11 @@ class ProcessGithubPullRequestEventService < ::BaseService
# and the pipeline is created for all newly pushed branches.
# At that point we will be able to reference it back if a pull request
# was created.
ExternalPullRequest.create_or_update_from_params(params) do |pr|
ExternalPullRequests::CreatePipelineService.new(project, current_user).execute(pr)
ExternalPullRequest.create_or_update_from_params(params).tap do |pull_request|
if pull_request.errors.empty?
ExternalPullRequests::CreatePipelineService.new(project, current_user)
.execute(pull_request)
end
end
end
......@@ -30,7 +33,7 @@ class ProcessGithubPullRequestEventService < ::BaseService
def params_from_webhook(params)
{
project_id: project.id,
pull_request_iid: params.dig(:pull_request, :id),
pull_request_iid: params.dig(:pull_request, :number),
source_branch: params.dig(:pull_request, :head, :ref),
source_sha: params.dig(:pull_request, :head, :sha),
source_repository: params.dig(:pull_request, :head, :repo, :full_name),
......
---
title: Use Pull Request number instead of internal Pull Request ID
merge_request: 16504
author:
type: fixed
......@@ -48,7 +48,7 @@ module API
# pull_request params
optional :action, type: String, desc: 'Pull Request action'
optional 'pull_request.id', type: Integer, desc: 'Pull request ID'
optional 'pull_request.number', type: Integer, desc: 'Pull request IID'
optional 'pull_request.head.ref', type: String, desc: 'Source branch'
optional 'pull_request.head.sha', type: String, desc: 'Source sha'
optional 'pull_request.head.repo.full_name', type: String, desc: 'Source repository'
......
......@@ -94,7 +94,7 @@ describe API::ProjectMirror do
let(:params) do
{
pull_request: {
id: 123,
number: 123,
head: {
ref: source_branch,
sha: source_sha,
......
......@@ -9,7 +9,7 @@ describe ProcessGithubPullRequestEventService do
let(:params) do
{
pull_request: {
id: 123,
number: 123,
head: {
ref: source_branch,
sha: source_sha,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment