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