Skip to content

Instantly share code, notes, and snippets.

@luke-gru
Created June 6, 2011 00:23
Show Gist options
  • Save luke-gru/1009581 to your computer and use it in GitHub Desktop.
Save luke-gru/1009581 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
if ARGV.empty?
repo_name = File.expand_path(".").split("/").last
elsif ARGV.count == 1 && !ARGV[0].match(/-[-]?/)
repo_name = ARGV[0]
end
begin
doc = Nokogiri::HTML(open("https://github.com/luke-gru/#{repo_name}"))
rescue OpenURI::HTTPError => nogit
puts "Not in a git repository!"
puts nogit.class
exit
end
doc.xpath('//div[@class = "message"]/pre').each do |node|
@commit_msg = node.text
end
doc.xpath('//div[@class = "actor"]/div[@class = "name"]').each do |node|
@commiter = node.text
end
#output starts here
doc.xpath('//div[@class = "machine"]').each do |node|
puts node.text.strip!.gsub(/\n/, '').gsub(/tree/, "\ntree").gsub(/parent.*?(\w)/, "\nparent \\1")
end
puts "#{@commit_msg} => #{@commiter}".gsub(/\(author\)/, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment