diff --git a/lib/grit/blob.rb b/lib/grit/blob.rb index 9593d562..e9c0c467 100644 --- a/lib/grit/blob.rb +++ b/lib/grit/blob.rb @@ -29,6 +29,22 @@ def create_initialize(repo, atts) self end + # The repo object of this blob + # + # Returning Grit::Repo + def repo + @repo + end + + # The path of this blob ( eg. lib/grit/blob.rb ) + # +treeish+ is the Commit + # + # Returns String + def path(treeish = 'master') + revs = @repo.git.native(:ls_tree, {:r => true}, treeish, "| grep #{@id}") + path = revs.split("\n").first.to_s.split("\t").last + end + # The size of this blob in bytes # # Returns Integer @@ -123,4 +139,4 @@ def <=>(other) end end # Blob -end # Grit \ No newline at end of file +end # Grit