Created
June 6, 2011 00:24
-
-
Save luke-gru/1009585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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