diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-03-09 16:24:02 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-03-14 13:20:35 +0100 |
commit | 0672258915a0cf444802ffc50ad1cd914f4f11d4 (patch) | |
tree | f8e389d36a5eb9a761e5b283fb0e2adddda60f9c /app/models/ci/commit.rb | |
parent | 37ba5a12b515172b76d28e112ab9899823163717 (diff) | |
download | gitlab-ce-0672258915a0cf444802ffc50ad1cd914f4f11d4.tar.gz |
Cleanup CiCommit and CiBuild
- Remove all view related methods from Ci::Build and CommitStatus
- Remove unused Ci::Commit and Ci::Build methods
- Use polymorphism to render different types of CommitStatus
Diffstat (limited to 'app/models/ci/commit.rb')
-rw-r--r-- | app/models/ci/commit.rb | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index ecbd2078b1d..12c60158d46 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -25,8 +25,6 @@ module Ci has_many :builds, class_name: 'Ci::Build' has_many :trigger_requests, dependent: :destroy, class_name: 'Ci::TriggerRequest' - scope :ordered, -> { order('CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) } - validates_presence_of :sha validate :valid_commit_sha @@ -42,16 +40,6 @@ module Ci project.id end - def last_build - builds.order(:id).last - end - - def retry - latest_builds.each do |build| - Ci::Build.retry(build) - end - end - def valid_commit_sha if self.sha == Gitlab::Git::BLANK_SHA self.errors.add(:sha, " cant be 00000000 (branch removal)") @@ -121,12 +109,8 @@ module Ci @latest_statuses ||= statuses.latest.to_a end - def latest_builds - @latest_builds ||= builds.latest.to_a - end - - def latest_builds_for_ref(ref) - latest_builds.select { |build| build.ref == ref } + def latest_statuses_for_ref(ref) + latest_statuses.select { |status| status.ref == ref } end def retried @@ -170,7 +154,7 @@ module Ci end def duration - duration_array = latest_statuses.map(&:duration).compact + duration_array = statuses.map(&:duration).compact duration_array.reduce(:+).to_i end @@ -183,16 +167,12 @@ module Ci end def coverage - coverage_array = latest_builds.map(&:coverage).compact + coverage_array = latest_statuses.map(&:coverage).compact if coverage_array.size >= 1 '%.2f' % (coverage_array.reduce(:+) / coverage_array.size) end end - def matrix_for_ref?(ref) - latest_builds_for_ref(ref).size > 1 - end - def config_processor return nil unless ci_yaml_file @config_processor ||= Ci::GitlabCiYamlProcessor.new(ci_yaml_file, project.path_with_namespace) @@ -218,10 +198,6 @@ module Ci git_commit_message =~ /(\[ci skip\])/ if git_commit_message end - def update_committed! - update!(committed_at: DateTime.now) - end - private def save_yaml_error(error) |