Skip to content

Instantly share code, notes, and snippets.

@vitaliel
Created July 16, 2009 15:08
Show Gist options
  • Save vitaliel/148462 to your computer and use it in GitHub Desktop.
Save vitaliel/148462 to your computer and use it in GitHub Desktop.
# Output with command
# git log --format="//%h/%ae/%ai/%s" --name-only --relative="iChart ASP.net/" -- iChart ASP.net/
#
class GitBrowseInfo
def initialize(str)
@str = str
end
def parse
sha = email = datetime = subject = nil
files = {}
@str.each_line do |line|
next if line.length < 2 # last char is \n
if line[0..1] == "//"
_, _, sha, email, datetime, subject = line.split('/', 6)
else # is a file path
# dir ?
if idx = line.index('/')
name = line[0..idx]
else
name = line.chomp
end
files[name] ||= [sha, email, datetime, subject.chomp]
end
end
require "pp"
pp files
# TODO sort them: dirs first
end
end
File.open("files.txt") do |f|
GitBrowseInfo.new(f.read).parse
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment