File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 13
13
throw ( :halt , 400 ) unless campfire && campfire . login ( data [ 'token' ] , 'X' )
14
14
throw ( :halt , 400 ) unless room = campfire . find_room_by_name ( data [ 'room' ] )
15
15
16
- message = "[#{ owner } /#{ repository } /#{ branch } ]\n "
17
- message += commits . map do |commit |
18
- short = commit [ 'message' ] . split ( "\n " , 2 ) . first
19
- short += ' ...' if short != commit [ 'message' ]
20
- "#{ commit [ 'id' ] [ 0 ..6 ] } #{ short } - #{ commit [ 'author' ] [ 'name' ] } "
21
- end . join ( "\n " )
16
+ prefix = "[#{ repository } /#{ branch } ]"
17
+ primary , others = commits [ 0 ..4 ] , Array ( commits [ 5 ..-1 ] )
18
+ messages =
19
+ primary . map do |commit |
20
+ short = commit [ 'message' ] . split ( "\n " , 2 ) . first
21
+ short += ' ...' if short != commit [ 'message' ]
22
+ "#{ prefix } #{ short } - #{ commit [ 'author' ] [ 'name' ] } "
23
+ end
22
24
23
- if commits . size > 1
25
+ if messages . size > 1
24
26
before , after = payload [ 'before' ] [ 0 ..6 ] , payload [ 'after' ] [ 0 ..6 ]
25
27
url = payload [ 'repository' ] [ 'url' ] + "/compare/#{ before } ...#{ after } "
28
+ summary =
29
+ if others . any?
30
+ "#{ prefix } (+#{ others . length } more) commits #{ before } ...#{ after } : #{ url } "
31
+ else
32
+ "#{ prefix } commits #{ before } ...#{ after } : #{ url } "
33
+ end
34
+ messages << summary
26
35
else
27
36
url = commits . first [ 'url' ]
37
+ messages [ 0 ] = "#{ messages . first } (#{ url } )"
28
38
end
29
39
30
- room . paste message
31
- room . speak url
40
+ messages . each { |line | room . speak line }
32
41
room . play "rimshot" if play_sound
33
42
34
43
room . leave
You can’t perform that action at this time.
0 commit comments