diff options
Diffstat (limited to 'app/models/ci/commit.rb')
-rw-r--r-- | app/models/ci/commit.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index f102d0a7679..6d048779cde 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -18,8 +18,8 @@ module Ci class Commit < ActiveRecord::Base extend Ci::Model - - belongs_to :project, class_name: 'Ci::Project' + + belongs_to :gl_project, class_name: '::Project', foreign_key: :gl_project_id has_many :builds, dependent: :destroy, class_name: 'Ci::Build' has_many :trigger_requests, dependent: :destroy, class_name: 'Ci::TriggerRequest' @@ -36,6 +36,14 @@ module Ci sha end + def project + @project ||= gl_project.ensure_gitlab_ci_project + end + + def project_id + project.id + end + def last_build builds.order(:id).last end @@ -111,15 +119,14 @@ module Ci builds_attrs = config_processor.builds_for_stage_and_ref(stage, ref, tag) builds_attrs.map do |build_attrs| builds.create!({ - project: project, - name: build_attrs[:name], - commands: build_attrs[:script], - tag_list: build_attrs[:tags], - options: build_attrs[:options], - allow_failure: build_attrs[:allow_failure], - stage: build_attrs[:stage], - trigger_request: trigger_request, - }) + name: build_attrs[:name], + commands: build_attrs[:script], + tag_list: build_attrs[:tags], + options: build_attrs[:options], + allow_failure: build_attrs[:allow_failure], + stage: build_attrs[:stage], + trigger_request: trigger_request, + }) end end |