diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-26 16:36:17 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-26 16:36:17 +0200 |
commit | cb90368a692149b4e01b50d7c6682c48cffa438b (patch) | |
tree | 6236d6f4fd56acad1015950d483db0ba8fa3ada9 /lib/api/commit_statuses.rb | |
parent | c6f19aed51736e5945283a611eae09f32a9b5aeb (diff) | |
parent | f127edd012bd8b6f76ac67d69aadbd7d4837258f (diff) | |
download | gitlab-ce-cb90368a692149b4e01b50d7c6682c48cffa438b.tar.gz |
Merge remote-tracking branch 'origin/master' into with-pipeline-view
Diffstat (limited to 'lib/api/commit_statuses.rb')
-rw-r--r-- | lib/api/commit_statuses.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index 0b52dd8a743..7388ed2f4ea 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -50,12 +50,19 @@ module API commit = @project.commit(params[:sha]) not_found! 'Commit' unless commit - ref = params[:ref] || - begin - branches = @project.repository.branch_names_contains(commit.sha) - not_found! 'Reference for commit' if branches.none? - branches.first - end + # Since the CommitStatus is attached to Ci::Commit (in the future Pipeline) + # We need to always have the pipeline object + # To have a valid pipeline object that can be attached to specific MR + # Other CI service needs to send `ref` + # If we don't receive it, we will attach the CommitStatus to + # the first found branch on that commit + + ref = params[:ref] + unless ref + branches = @project.repository.branch_names_contains(commit.sha) + not_found! 'References for commit' if branches.none? + ref = branches.first + end ci_commit = @project.ensure_ci_commit(commit.sha, ref) |