Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-29 18:06:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-29 18:06:43 +0300
commiteac0da9a47f0c7b8b970833d7d5b96cfee057bf7 (patch)
tree7b7865053435c6dcb4e2d945fcf45e309331c91b /app/models/environment_status.rb
parentb860c6ba2607541e3b5bdf0fc2daaa9ed41a8726 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/environment_status.rb')
-rw-r--r--app/models/environment_status.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb
index 3eca8c91e40..5fdb5af2d9b 100644
--- a/app/models/environment_status.rb
+++ b/app/models/environment_status.rb
@@ -20,6 +20,28 @@ class EnvironmentStatus
build_environments_status(mr, user, mr.merge_pipeline)
end
+ def self.for_deployed_merge_request(mr, user)
+ statuses = []
+
+ mr.recent_visible_deployments.each do |deploy|
+ env = deploy.environment
+
+ next unless Ability.allowed?(user, :read_environment, env)
+
+ statuses <<
+ EnvironmentStatus.new(deploy.project, env, mr, deploy.sha)
+ end
+
+ # Existing projects that used deployments prior to the introduction of
+ # explicitly linked merge requests won't have any data using this new
+ # approach, so we fall back to retrieving deployments based on CI pipelines.
+ if statuses.any?
+ statuses
+ else
+ after_merge_request(mr, user)
+ end
+ end
+
def initialize(project, environment, merge_request, sha)
@project = project
@environment = environment