Created
September 9, 2010 18:26
-
-
Save guilleiguaran/572280 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
require "rubygems" | |
require "grit" | |
include Grit | |
def transversal_path(node, level) | |
node.contents.each do |child| | |
if child.class == Grit::Blob | |
puts " "*level*2+" "+child.name | |
else | |
puts " "*level*2+" "+"[#{child.name}]" | |
transversal_path(child, level+1) | |
end | |
end | |
return nil | |
end | |
repo = Repo.new(Dir.pwd) | |
root = repo.commits.first.tree | |
transversal_path(root, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment