git_repository.rb revision f1304db188bff0f7c40172819863ffe54401b400
# Wrapper for access to the local Git repository
include \
if File.exists?(path)
else
end
end
end
if @repo.empty?
else
end
end
if !rugged_commit && url.empty?
true
else
end
end
if !rugged_commit && url.empty?
else
end
end
url ||= ''
end
end
@repo.refs.map do |r|
{
}
end
end
file_path << file_name
file_path
end
def is_head?(commit_oid=nil)
commit_oid == nil || (!@repo.empty? && commit_oid == head_oid)
end
protected
def path_exists_rugged?(rugged_commit, url='')
if url.empty?
true
else
tree = rugged_commit.tree
nil != get_object(rugged_commit, url)
end
rescue Rugged::OdbError
false
end
def get_current_file_rugged(rugged_commit, url='')
return nil unless path_exists_rugged?(rugged_commit, url)
object = get_object(rugged_commit, url)
if object.type == :blob
filename = url.split('/')[-1]
mime_info = mime_info(filename)
{
name: filename,
size: object.size,
content: object.content,
mime_type: mime_info[:mime_type],
mime_category: mime_info[:mime_category]
}
else
nil
end
end
# NOTE: "destroy repository" function not inserted here
def head_oid
@repo.head.target
end
def head
@repo.lookup(head_oid)
end
end