git_repository.rb revision afd1d888784385307c9c0544597a513c2008d342
# Wrapper for access to the local Git repository
# requires git and git-svn to be installed for the functions clone_git and clone_svn to work
require 'git_repository/config'
include \
if File.exists?(path)
else
end
end
# DELETEME (exists only for debugging purpose)
@repo
end
end
end
path ||= '/'
if empty?
return false
end
end
if !rugged_commit && url.empty?
true
else
end
end
end
end
path ||= '/'
end
path ||= ''
end
end
@repo.refs.map do |r|
{
}
end
end
if ref.nil?
else
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
def head_oid
if @repo.empty?
nil
else
@repo.head.target
end
end
def self.is_repository_with_working_copy?(path)
repo = Rugged::Repository.new(path)
!repo.bare?
rescue Rugged::RepositoryError
false
end
def self.is_bare_repository?(path)
Rugged::Repository.new(path).bare?
rescue Rugged::RepositoryError
false
end
def self.mime_type_editable?(mime_type)
mime_type.to_s == 'application/xml' || mime_type.to_s.match(/^text\/.*/)
end
def self.mime_info(filename)
ext = File.extname(filename)[1..-1]
mime_type = Mime::Type.lookup_by_extension(ext) || Mime::TEXT
mime_category = mime_type.to_s.split('/')[0]
{
mime_type: mime_type,
mime_category: mime_category
}
end
protected
def path_exists_rugged?(rugged_commit, url='')
if url.empty?
true
else
nil != get_object(rugged_commit, url)
end
rescue Rugged::OdbError
false
end
def head
@repo.lookup(head_oid)
end
end