limit commit count to three messages

This commit is contained in:
Emil Loer
2010-12-14 12:00:12 +01:00
parent a550fc45ed
commit bdfd8f83ca
+12 -2
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require "datetime"
require "cinch"
require "sinatra"
require "yaml"
@@ -52,10 +53,19 @@ post "/github" do
repo = push["repository"]["name"]
branch = push["ref"].gsub(/^refs\/heads\//,"")
# TODO: sort commits by timestamp
push["commits"].each do |c|
# sort commits by timestamp
push["commits"].sort! do |a,b|
DateTime.parse(a["timestamp"]) <=> DateTime.parse(b["timestamp"])
end
# output first 3 commits
push["commits"][0..2].each do |c|
say "\0030#{repo}:\0037 #{branch}\0033 #{c["author"]["name"]}\003 #{c["message"]}"
end
if push["commits"].length-2 > 0
say "\0030#{repo}:\0037 #{branch}\003 ... and #{push["commits"].length-2} more"
end
push.inspect
end