Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created September 9, 2010 18:26
Show Gist options
  • Save guilleiguaran/572280 to your computer and use it in GitHub Desktop.
Save guilleiguaran/572280 to your computer and use it in GitHub Desktop.
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