Permalink
Browse files

Merge remote branch 'origin/master'

Integrated the name-change

Conflicts:
	services/travis.rb
  • Loading branch information...
kronn committed Mar 2, 2011
2 parents 5ef25f1 + 89f45fc commit 2bc46eda9b7c322ab6aa345a32df9cf6b9f3c496
View
@@ -56,3 +56,4 @@ Thanks to the following people for making this possible
- Alex Ezell
- Serge Smetana
- Matthias Viehweger
- Justin Mazzi
View
@@ -6,9 +6,11 @@
},
"payload" => {
"after" => "a47fd41f3aa4610ea527dcc1669dfdb9c15c5425",
"ref" => "refs/heads/master",
"before" => "4c8124ffcf4039d292442eeccabdeca5af5c5017",
"after" => "a47fd41f3aa4610ea527dcc1669dfdb9c15c5425",
"ref" => "refs/heads/master",
"before" => "4c8124ffcf4039d292442eeccabdeca5af5c5017",
"compare" => "http://github.com/mojombo/grit/compare/4c8124ffcf4039d292442eeccabdeca5af5c5017...a47fd41f3aa4610ea527dcc1669dfdb9c15c5425",
"forced" => false,
"repository" => {
"name" => "grit",
View
@@ -4,16 +4,21 @@ Jaconda
Install Notes
-------------
1. Room ID is the numerical ID of your room, it can be found on the Room Integration page
2. API token is also displayed on the Room Integration page too
3. if Digest is checked, all commits will be compressed in one message
Using the following url as an example:
https://bigbang.jaconda.im/rooms/galaxo
1. Subdomain is bigbang
2. Room ID is galaxo
3. Room token can be found on the Room Integration page
4. if Digest is checked, all commits will be compressed in one message
Developer Notes
---------------
data
- subdomain
- room_id
- api_token
- room_token
- digest (boolean)
payload
File renamed without changes.
View
@@ -1,13 +1,13 @@
def build_cia_commit(repository, branch, sha1, commit, size = 1)
def build_cia_commit(data, repository, branch, sha1, commit, size = 1)
log = commit['message']
log << " (+#{size} more commits...)" if size > 1
dt = DateTime.parse(commit['timestamp']).new_offset
timestamp = Time.send(:gm, dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec).to_i
files = commit['modified'] + commit['added'] + commit['removed']
tiny_url = shorten_url(commit['url'])
tiny_url = data['long_url'].to_i == 1 ? commit['url'] : shorten_url(commit['url'])
log << " - #{tiny_url}" unless tiny_url == commit['url']
log << " - #{tiny_url}"
<<-MSG
<message>
@@ -44,12 +44,12 @@ def build_cia_commit(repository, branch, sha1, commit, size = 1)
commits = payload['commits']
if commits.size > 5
message = build_cia_commit(repository, branch, payload['after'], commits.last, commits.size - 1)
message = build_cia_commit(data, repository, branch, payload['after'], commits.last, commits.size - 1)
server.call("hub.deliver", message)
else
commits.each do |commit|
sha1 = commit['id']
message = build_cia_commit(repository, branch, sha1, commit)
message = build_cia_commit(data, repository, branch, sha1, commit)
server.call("hub.deliver", message)
end
end
View
@@ -59,6 +59,8 @@
EOH
end
body << "Compare: #{payload['compare']}" if payload['commits'].size > 1
begin
message = TMail::Mail.new
message.set_content_type('text', 'plain', {:charset => 'UTF-8'})
View
@@ -1,46 +1,23 @@
service :jaconda do |data, payload|
throw(:halt, 400) if data['api_token'].to_s == '' || data['room_id'].to_s == ''
throw :halt, [400, "Missing 'subdomain'"] if data['subdomain'].to_s == ''
throw :halt, [400, "Missing 'room_id'"] if data['room_id'].to_s == ''
throw :halt, [400, "Missing 'room_token'"] if data['room_token'].to_s == ''
repository = CGI.escapeHTML(payload['repository']['name'])
branch = CGI.escapeHTML(payload['ref_name'])
commits = payload['commits']
api_token = data['api_token']
room_id = data['room_id']
url = URI.parse("https://#{api_token.strip}:X@jaconda.im/api/rooms/#{room_id}/messages.json")
url = URI.parse("https://#{data['subdomain']}.jaconda.im/api/v2/rooms/#{data['room_id']}/notify/github.json")
req = Net::HTTP::Post.new(url.path)
req.set_form_data({
:payload => JSON.generate(payload),
:digest => data['digest']
})
req.basic_auth data['room_token'], "x"
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
res = nil
http.start { |http| res = http.request(req) }
before, after = payload['before'][0..6], payload['after'][0..6]
compare_url = payload['repository']['url'] + "/compare/#{before}...#{after}"
if data['digest'].to_i == 1 && commits.size > 1
commit = commits.first
message = "<i>Commit <a href='#{commit["url"]}'>#{commit["id"][0..6]}</a> on #{repository}/#{branch} by #{CGI.escapeHTML(commit["author"]["name"])}</i><br /><br />"
message += CGI.escapeHTML(commit["message"])
message += "<br /><br /><i>(+#{commits.size - 1} <a href='#{compare_url}'>more commits</a>)</i>"
req = Net::HTTP::Post.new(url.path)
req.set_form_data(:text => message)
req.basic_auth url.user, url.password
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
res = nil
http.start { |http| res = http.request(req) }
throw(:halt, [res.code.to_i, res.body.to_s]) unless res.is_a?(Net::HTTPSuccess)
if res.is_a?(Net::HTTPSuccess)
true
else
commits.each do |commit|
message = "<i>Commit <a href='#{commit["url"]}'>#{commit["id"][0..6]}</a> on #{repository}/#{branch} by #{CGI.escapeHTML(commit["author"]["name"])}</i><br /><br />"
message += CGI.escapeHTML(commit["message"])
req = Net::HTTP::Post.new(url.path)
req.set_form_data(:text => message)
req.basic_auth url.user, url.password
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
res = nil
http.start { |http| res = http.request(req) }
throw(:halt, [res.code.to_i, res.body.to_s]) unless res.is_a?(Net::HTTPSuccess)
end
throw :halt, [res.code.to_i, res.body.to_s]
end
true
end
end
@@ -1,4 +1,4 @@
service :travis_ci do |data, payload|
service :travis do |data, payload|
user = (data['user'] || payload['repository']['owner']['name']).strip
token = (data['token']).strip
domain = (data['domain'] || 'http://travis-ci.org').strip

0 comments on commit 2bc46ed

Please sign in to comment.