diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-06 16:44:45 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-21 14:49:36 +0100 |
commit | ae8f755fc81160b695e44bbfb00b1225527bf5f9 (patch) | |
tree | 755e60bad6f63014e3ae7eea8cd0ad018a611956 /app/models/commit.rb | |
parent | 1ba150e1cf346239eafec3d530b3de3325501893 (diff) | |
download | gitlab-ci-ae8f755fc81160b695e44bbfb00b1225527bf5f9.tar.gz |
Initial support for build triggers
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index a27c86b..6195090 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -2,21 +2,23 @@ # # Table name: commits # -# id :integer not null, primary key -# project_id :integer -# ref :string(255) -# sha :string(255) -# before_sha :string(255) -# push_data :text -# created_at :datetime -# updated_at :datetime -# tag :boolean default(FALSE) -# yaml_errors :text +# id :integer not null, primary key +# project_id :integer +# ref :string(255) +# sha :string(255) +# before_sha :string(255) +# push_data :text +# created_at :datetime +# updated_at :datetime +# tag :boolean default(FALSE) +# yaml_errors :text +# committed_at :datetime # class Commit < ActiveRecord::Base belongs_to :project has_many :builds, dependent: :destroy + has_many :trigger_requests, dependent: :destroy serialize :push_data @@ -99,7 +101,7 @@ class Commit < ActiveRecord::Base config_processor.stages.find { |stage| stages.include? stage } end - def create_builds_for_stage(stage) + def create_builds_for_stage(stage, trigger_request) return if skip_ci? return unless config_processor @@ -112,28 +114,29 @@ class Commit < ActiveRecord::Base tag_list: build_attrs[:tags], options: build_attrs[:options], allow_failure: build_attrs[:allow_failure], - stage: build_attrs[:stage] + stage: build_attrs[:stage], + trigger_request: trigger_request, }) end end - def create_next_builds + def create_next_builds(trigger_request) return if skip_ci? return unless config_processor - stages = builds.group_by(&:stage) + stages = builds.where(trigger_request: trigger_request).group_by(&:stage) config_processor.stages.any? do |stage| - !stages.include?(stage) && create_builds_for_stage(stage).present? + !stages.include?(stage) && create_builds_for_stage(stage, trigger_request).present? end end - def create_builds + def create_builds(trigger_request = nil) return if skip_ci? return unless config_processor config_processor.stages.any? do |stage| - create_builds_for_stage(stage).present? + create_builds_for_stage(stage, trigger_request).present? end end |