From 1cf1e7bedbddc326d2551e984d6bac8f1027ede8 Mon Sep 17 00:00:00 2001 From: Stefan Kanev Date: Tue, 29 Jul 2014 11:04:19 +0300 Subject: Less verbose HipChat integration Whenever a push with a lot of merges is made, the HipChat channel gets overwhelmed. It is easy to loose everything else in all the GitLab messages. It makes more sense to limit the number of commits shown. The same problem happens with longer commit messages (like this one). It will be useful to show only the subject of the commit message, not the full one. --- app/models/project_services/hipchat_service.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index 9c6fe7dab21..48fe365760b 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -18,6 +18,8 @@ # class HipchatService < Service + MAX_COMMITS = 3 + validates :token, presence: true, if: :activated? def title @@ -64,8 +66,13 @@ class HipchatService < Service message << "pushed to branch #{ref} " message << "of #{project.name_with_namespace.gsub!(/\s/,'')} " message << "(Compare changes)" - for commit in push[:commits] do - message << "
- #{commit[:message]} (#{commit[:id][0..5]})" + + push[:commits].take(MAX_COMMITS).each do |commit| + message << "
- #{commit[:message].lines.first} (#{commit[:id][0..5]})" + end + + if push[:commits].count > MAX_COMMITS + message << "
... #{push[:commits].count - MAX_COMMITS} more commits" end end -- cgit v1.2.1