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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-11-21 21:40:04 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-11-21 23:36:22 +0300
commit41aa605d4ed3d0d302c70ecd01052115f818f949 (patch)
tree392a694c913591493ed2de4de5c46acaf5222082 /lib/gitlab/chat_commands
parentd375e3f15b6f0340addb9a20e0c03a1f1fca413a (diff)
Improve deploy command message
Diffstat (limited to 'lib/gitlab/chat_commands')
-rw-r--r--lib/gitlab/chat_commands/deploy.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab/chat_commands/deploy.rb b/lib/gitlab/chat_commands/deploy.rb
index c0b93cca68c..0eed1fce0dc 100644
--- a/lib/gitlab/chat_commands/deploy.rb
+++ b/lib/gitlab/chat_commands/deploy.rb
@@ -1,6 +1,8 @@
module Gitlab
module ChatCommands
class Deploy < BaseCommand
+ include Gitlab::Routing.url_helpers
+
def self.match(text)
/\Adeploy\s+(?<from>.*)\s+to+\s+(?<to>.*)\z/.match(text)
end
@@ -25,7 +27,7 @@ module Gitlab
return unless actions.present?
if actions.one?
- actions.first.play(current_user)
+ play!(from, to, actions.first)
else
Result.new(:error, 'Too many actions defined')
end
@@ -33,12 +35,23 @@ module Gitlab
private
+ def play!(from, to, action)
+ new_action = action.play(current_user)
+
+ Result.new(:success, "Deployment from #{from} to #{to} started. Follow the progress: #{url(new_action)}.")
+ end
+
def find_actions(from, to)
environment = project.environments.find_by(name: from)
return unless environment
environment.actions_for(to).select(&:starts_environment?)
end
+
+ def url(subject)
+ polymorphic_url(
+ [ subject.project.namespace.becomes(Namespace), subject.project, subject ])
+ end
end
end
end