summaryrefslogtreecommitdiff
path: root/lib/api/commit_statuses.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-16 22:43:40 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-16 22:43:40 +0200
commit1c5b172abb1279a25731d35ee913daa91738606d (patch)
treefb523f73d57cb6b3ad216fc6f74ceeb877edba03 /lib/api/commit_statuses.rb
parentdc0d7f1a9b4018541596680c643cc5489fd8e625 (diff)
downloadgitlab-ce-1c5b172abb1279a25731d35ee913daa91738606d.tar.gz
Write specs for this feature
Diffstat (limited to 'lib/api/commit_statuses.rb')
-rw-r--r--lib/api/commit_statuses.rb19
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)