mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
43 lines
672 B
Ruby
43 lines
672 B
Ruby
module Gitlab
|
|
module Git
|
|
class Blob
|
|
include Linguist::BlobHelper
|
|
|
|
attr_accessor :raw_blob
|
|
|
|
delegate :name, to: :raw_blob
|
|
|
|
def initialize(repository, sha, ref, path)
|
|
@repository, @sha, @ref = repository, sha, ref
|
|
|
|
@commit = @repository.commit(sha)
|
|
@raw_blob = @repository.tree(@commit, path)
|
|
end
|
|
|
|
def data
|
|
if raw_blob
|
|
raw_blob.data
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def exists?
|
|
raw_blob
|
|
end
|
|
|
|
def empty?
|
|
data.blank?
|
|
end
|
|
|
|
def mode
|
|
raw_blob.mode
|
|
end
|
|
|
|
def size
|
|
raw_blob.size
|
|
end
|
|
end
|
|
end
|
|
end
|