Skip to content

Instantly share code, notes, and snippets.

@alk
Created October 15, 2012 19:27
Show Gist options
  • Select an option

  • Save alk/3894643 to your computer and use it in GitHub Desktop.

Select an option

Save alk/3894643 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'restclient'
require 'nokogiri'
require 'active_support/core_ext'
require 'uri/http'
def get!(url)
RestClient::Request.execute(:method => :get, :url => url)
end
BASE_URL = 'http://builds.hq.northscale.net/latestbuilds/'
def url_from_path(path)
path_url = URI.parse(path)
return path unless path_url.host.nil?
unless path_url.absolute?
return BASE_URL + path
end
base = URI.parse(BASE_URL)
URI::HTTP.build(:scheme => base.scheme,
:userinfo => base.userinfo,
:host => base.host,
:port => base.port,
:path => path).to_s
end
def fetch_manifest(build_nr)
body = get!(BASE_URL)
doc = Nokogiri::HTML(body)
el = doc.css("a").find do |cel|
href = cel.attributes['href']
next unless href
href = href.value
href.include?(build_nr) &&
href =~ /manifest.xml$/
end
url = url_from_path(el.attributes['href'].value)
manifest_body = get!(url)
elements = Nokogiri::XML(manifest_body).css("project")
Hash[elements.map {|e| a = e.attributes; [a['name'].value, a['revision'].value]}]
end
rev1 = ARGV[0] || (raise "want rev1 and rev2")
rev2 = ARGV[1] || (raise "want rev1 and rev2")
man1 = fetch_manifest(rev1)
man2 = fetch_manifest(rev2)
stuff = Dir['*']
different = {}
man2.each_key do |k|
next unless stuff.include? k
next unless man1.include? k
m1r = man1[k]
m2r = man2[k]
next if m1r == m2r
different[k] = (m1r..m2r)
end
different.to_a.sort.each do |(project, diff)|
puts "project: #{project} https://github.com/couchbase/#{project}/compare/#{diff.first}...#{diff.last}"
Dir.chdir(project) do
lines = `git log --oneline #{diff.first}..#{diff.last}`.split("\n")
lines.map! do |l|
if l =~ /^([a-z0-9]+) /
l + " https://github.com/couchbase/#{project}/commit/#{$1}"
else
l
end
end
puts lines
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment