Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created September 9, 2010 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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