summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kanev <stefan.kanev@gmail.com>2014-07-29 11:04:19 +0300
committerStefan Kanev <stefan.kanev@gmail.com>2014-07-29 11:04:19 +0300
commit1cf1e7bedbddc326d2551e984d6bac8f1027ede8 (patch)
tree06e5896c50ac83b96f5f5fe2e615c5aaee41dad7
parentd30454e112378c24cc9edfd7b511ca42bdb1e399 (diff)
downloadgitlab-ce-1cf1e7bedbddc326d2551e984d6bac8f1027ede8.tar.gz
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.
-rw-r--r--app/models/project_services/hipchat_service.rb11
1 files 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 <a href=\"#{project.web_url}/commits/#{ref}\">#{ref}</a> "
message << "of <a href=\"#{project.web_url}\">#{project.name_with_namespace.gsub!(/\s/,'')}</a> "
message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)"
- for commit in push[:commits] do
- message << "<br /> - #{commit[:message]} (<a href=\"#{commit[:url]}\">#{commit[:id][0..5]}</a>)"
+
+ push[:commits].take(MAX_COMMITS).each do |commit|
+ message << "<br /> - #{commit[:message].lines.first} (<a href=\"#{commit[:url]}\">#{commit[:id][0..5]}</a>)"
+ end
+
+ if push[:commits].count > MAX_COMMITS
+ message << "<br />... #{push[:commits].count - MAX_COMMITS} more commits"
end
end