summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2016-12-23 12:28:54 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-23 10:50:49 -0200
commit8dd85ca8347b00229364c2f6ea842934c09057b4 (patch)
treedd69ccd5d2d700a5e8bd95ec8f4d980b2aa0a71e /app
parent2f0d7871c258085b910d6e47c319a38528d7a8d1 (diff)
downloadgitlab-ce-8dd85ca8347b00229364c2f6ea842934c09057b4.tar.gz
Merge branch 'fix-latest-pipeine-ordering' into 'master'
Fix code that selects latest pipelines Closes #25993 and #26031 See merge request !8286
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb7
-rw-r--r--app/models/project.rb2
2 files changed, 3 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index f2f6453b3b9..6894a5763ff 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -93,11 +93,8 @@ module Ci
.select("max(#{quoted_table_name}.id)")
.group(:ref, :sha)
- if ref
- where(id: max_id, ref: ref)
- else
- where(id: max_id)
- end
+ relation = ref ? where(ref: ref) : self
+ relation.where(id: max_id).order(id: :desc)
end
def self.latest_status(ref = nil)
diff --git a/app/models/project.rb b/app/models/project.rb
index 26fa20f856d..72fdd4514c4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -418,7 +418,7 @@ class Project < ActiveRecord::Base
repository.commit(ref)
end
- # ref can't be HEAD, can only be branch/tag name or SHA
+ # ref can't be HEAD or SHA, can only be branch/tag name
def latest_successful_builds_for(ref = default_branch)
latest_pipeline = pipelines.latest_successful_for(ref)