summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-08-09 15:11:14 +0200
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-08-12 10:43:04 +0200
commit07fc2f852a0b4136b6d97c1d9773819c47e7e8e7 (patch)
treeb80f5200b1d7398eadc9b7ae029873f3cc6ad93a /app
parent03ea01946524a74773b24430c81804c2724b84b6 (diff)
downloadgitlab-ce-07fc2f852a0b4136b6d97c1d9773819c47e7e8e7.tar.gz
Method names changed to #includes_commit?zj-deployment-status-on-mr
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/pages/merge_requests.scss5
-rw-r--r--app/models/deployment.rb3
-rw-r--r--app/models/environment.rb4
-rw-r--r--app/models/merge_request.rb4
-rw-r--r--app/views/projects/merge_requests/widget/_heading.html.haml9
5 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss
index 0a661e529f0..b4636269518 100644
--- a/app/assets/stylesheets/pages/merge_requests.scss
+++ b/app/assets/stylesheets/pages/merge_requests.scss
@@ -69,6 +69,10 @@
&.ci-success {
color: $gl-success;
+
+ a.environment {
+ color: inherit;
+ }
}
&.ci-success_with_warnings {
@@ -126,7 +130,6 @@
&.has-conflicts .fa-exclamation-triangle {
color: $gl-warning;
}
-
}
p:last-child {
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 19b08f49d96..1e338889714 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -37,8 +37,7 @@ class Deployment < ActiveRecord::Base
deployable.try(:other_actions)
end
- def deployed_to?(ref)
- commit = project.commit(ref)
+ def includes_commit?(commit)
return false unless commit
project.repository.is_ancestor?(commit.id, sha)
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 7247125f8a0..75e6f869786 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -26,9 +26,9 @@ class Environment < ActiveRecord::Base
self.external_url = nil if self.external_url.blank?
end
- def deployed_from?(ref)
+ def includes_commit?(commit)
return false unless last_deployment
- last_deployment.deployed_to?(ref)
+ last_deployment.includes_commit?(commit)
end
end
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 945b0d76505..491ee2792ec 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -591,8 +591,10 @@ class MergeRequest < ActiveRecord::Base
end
def environments
+ return unless diff_head_commit
+
target_project.environments.select do |environment|
- environment.deployed_from?(ref_path)
+ environment.includes_commit?(diff_head_commit)
end
end
diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml
index 16e923b831c..494695a03a5 100644
--- a/app/views/projects/merge_requests/widget/_heading.html.haml
+++ b/app/views/projects/merge_requests/widget/_heading.html.haml
@@ -45,10 +45,13 @@
- @merge_request.environments.each do |environment|
.mr-widget-heading
- .ci_widget{ class: "ci-success" }
+ .ci_widget.ci-success
= ci_icon_for_status("success")
%span.hidden-sm
- Released to #{environment.name}.
+ Deployed to
+ = succeed '.' do
+ = link_to environment.name, namespace_project_environment_path(@project.namespace, @project, environment), class: 'environment'
- external_url = environment.external_url
- if external_url
- = link_to icon('external-link', text: "View on #{external_url.gsub(/\A.*?:\/\//, '')}"), external_url
+ = link_to external_url, target: '_blank' do
+ = icon('external-link', text: "View on #{external_url.gsub(/\A.*?:\/\//, '')}", right: true)