From 23bb9424c0f0f872cb33e61169a56abe5e7e6985 Mon Sep 17 00:00:00 2001 From: charlieablett Date: Mon, 2 Sep 2019 17:35:45 +1200 Subject: Handle projectless `help` commands to chatops - Pass in a nil project to Gitlab::SlashCommands::ApplicationHelp.new if the chatops command is help. - Modify the Gitlab::SlashCommands::Presenters::Help message to skip printing out project information. --- lib/gitlab/slash_commands/presenters/help.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/gitlab/slash_commands/presenters/help.rb b/lib/gitlab/slash_commands/presenters/help.rb index 5421b0b9a84..bb2298f8395 100644 --- a/lib/gitlab/slash_commands/presenters/help.rb +++ b/lib/gitlab/slash_commands/presenters/help.rb @@ -43,16 +43,22 @@ module Gitlab end def help_footer + <<~MESSAGE + #{project_info if @project} + *Documentation* + + For more information about GitLab chatops, refer to its + documentation: https://docs.gitlab.com/ce/ci/chatops/README.html. + MESSAGE + end + + def project_info <<~MESSAGE *Project* The GitLab project for this chatops integration can be found at #{url_for(@project)}. - *Documentation* - - For more information about GitLab chatops, refer to its - documentation: https://docs.gitlab.com/ce/ci/chatops/README.html. MESSAGE end -- cgit v1.2.1 From c3c84ff8eaff87e9e8ec76b7d1d10e5495724d34 Mon Sep 17 00:00:00 2001 From: charlieablett Date: Mon, 2 Sep 2019 17:52:11 +1200 Subject: Tidy up conditional message --- lib/gitlab/slash_commands/presenters/help.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/slash_commands/presenters/help.rb b/lib/gitlab/slash_commands/presenters/help.rb index bb2298f8395..342dae456a8 100644 --- a/lib/gitlab/slash_commands/presenters/help.rb +++ b/lib/gitlab/slash_commands/presenters/help.rb @@ -43,13 +43,15 @@ module Gitlab end def help_footer - <<~MESSAGE - #{project_info if @project} - *Documentation* + message = @project ? project_info : '' + message += <<~MESSAGE + *Documentation* - For more information about GitLab chatops, refer to its - documentation: https://docs.gitlab.com/ce/ci/chatops/README.html. + For more information about GitLab chatops, refer to its + documentation: https://docs.gitlab.com/ce/ci/chatops/README.html. MESSAGE + + message end def project_info -- cgit v1.2.1