Skip to content
This repository was archived by the owner on Apr 19, 2018. It is now read-only.

Get blob path (eg. @blob.path = 'lib/grit/blob.rb') #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/grit/blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,4 +139,4 @@ def <=>(other)
end
end # Blob

end # Grit
end # Grit