summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/pipeline.rb7
-rw-r--r--app/models/project.rb2
2 files changed, 6 insertions, 3 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 6894a5763ff..f2f6453b3b9 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -93,8 +93,11 @@ module Ci
.select("max(#{quoted_table_name}.id)")
.group(:ref, :sha)
- relation = ref ? where(ref: ref) : self
- relation.where(id: max_id).order(id: :desc)
+ if ref
+ where(id: max_id, ref: ref)
+ else
+ where(id: max_id)
+ end
end
def self.latest_status(ref = nil)
diff --git a/app/models/project.rb b/app/models/project.rb
index 72fdd4514c4..26fa20f856d 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 or SHA, can only be branch/tag name
+ # ref can't be HEAD, can only be branch/tag name or SHA
def latest_successful_builds_for(ref = default_branch)
latest_pipeline = pipelines.latest_successful_for(ref)