summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-31 13:35:40 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-31 13:35:40 +0200
commit1fa3a20855ff907f4b93ba2f4198cabc9fc9e30e (patch)
treecab942317e168b93903ccc10d9b3a4d5aae86cf6 /lib/api
parent08d91d8dc20394d531ce7169e3685056bf6053e4 (diff)
parent18f954b31c242822b6c7430a50ca99a93adc6ea6 (diff)
downloadgitlab-ci-1fa3a20855ff907f4b93ba2f4198cabc9fc9e30e.tar.gz
Merge branch 'enhancement/separate-commits-from-builds' of https://gitlab.com/kestred/gitlab-ci into kestred/gitlab-ci-enhancement/separate-commits-from-builds
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: CHANGELOG app/models/build.rb app/services/create_build_service.rb db/schema.rb
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/builds.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 6ecc248..f96c1d4 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -14,9 +14,12 @@ module API
required_attributes! [:token]
ActiveRecord::Base.transaction do
- builds = Build.all
- builds = builds.where(project_id: current_runner.projects) unless current_runner.shared?
- build = builds.first_pending
+ build = if current_runner.shared?
+ Build.first_pending
+ else
+ commits = Commit.where(project_id: current_runner.projects)
+ Build.where(commit_id: commits).first_pending
+ end
not_found! and return unless build