# 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'
if File.exists?(path)
else
end
end
end
end
path ||= '/'
if empty?
return false
end
end
return false if empty?
if !rugged_commit && path.empty?
true
else
end
end
contents.map { |git_file| git_file.path }.
end
def get_file(path, commit_oid = nil)
end
end
def get_file!(path, commit_oid = nil)
path ||= '/'
end
path ||= ''
end
end
path ||= '/'
if dir.nil?
dir = path if dir?(path, commit_oid)
end
end
end
# Given a commit oid or a branch name, commit_id returns a hash of oid and
# branch name if existent.
else
end
end
{oid: oid, branch_name: branch_names.empty? ? nil : branch_names[0][:name]}
end
else
end
end
branches.select { |b| b[:oid] == oid }
end
repo.refs.map do |ref|
{
}
end
end
if ref.nil?
else
end
end
if commit = branch_commit(name)
end
end
file_path << file_name
file_path
end
def is_head?(commit_oid=nil)
commit_oid.nil? || (!empty? && commit_oid == head_oid)
end
def head_oid
if empty?
nil
else
repo.head.target.oid
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, path = '/')
path.empty? || !get_object(rugged_commit, path).nil?
rescue Rugged::OdbError
false
end
def head
repo.lookup(head_oid)
end
end