diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-18 23:17:43 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-18 23:18:16 +0800 |
commit | 57a78c37c72b2d697bc863ebfb84d3ca61ba9d7b (patch) | |
tree | 6b3778b5a62e4c01131f1f8291027033a798bf08 /app/models | |
parent | 72699d9719a269a82be6af0812d86d84733c77bd (diff) | |
download | gitlab-ce-57a78c37c72b2d697bc863ebfb84d3ca61ba9d7b.tar.gz |
Show notice if builds are not from latest pipeline
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 3 | ||||
-rw-r--r-- | app/models/project.rb | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index ffac3a22efc..9af04964b85 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -15,6 +15,9 @@ module Ci scope :with_artifacts, ->() { where.not(artifacts_file: nil) } scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) } scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } + scope :latest_success_with_artifacts, ->() do + with_artifacts.success.latest + end mount_uploader :artifacts_file, ArtifactUploader mount_uploader :artifacts_metadata, ArtifactUploader diff --git a/app/models/project.rb b/app/models/project.rb index 12851c5d0ec..77431c3f538 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -429,10 +429,16 @@ class Project < ActiveRecord::Base repository.commit(ref) end - def latest_success_builds_for(ref = 'HEAD') + # ref can't be HEAD or SHA, can only be branch/tag name + def latest_success_pipeline_for(ref = 'master') + pipelines.where(ref: ref).success.latest + end + + # ref can't be HEAD or SHA, can only be branch/tag name + def latest_success_builds_for(ref = 'master') Ci::Build.joins(:pipeline). - merge(pipelines.where(ref: ref).success.latest). - with_artifacts.success.latest + merge(latest_success_pipeline_for(ref)). + latest_success_with_artifacts end def merge_base_commit(first_commit_id, second_commit_id) |