git_repositories.rb revision 0a19ed12e51e3aba6ad5fd1543a6fb3aeb3dd7e9
included do
end
end
end
"#{Ontohub::Application.config.git_root}/#{id}"
end
"#{Ontohub::Application.config.git_working_copies_root}/#{id}"
end
end
end
end
end
if o
# update existing ontology
version = o.versions.build({ :commit_oid => commit_oid, :user => user }, { without_protection: true })
else
# create new ontology
o = clazz.new
o.iri = iri || "http://#{Settings.hostname}/#{path}/#{basepath}"
version = o.versions.build({ :commit_oid => commit_oid, :user => user }, { without_protection: true })
end
end
path ||= '/'
end
path ||= '/'
if path_exists?(path, commit_oid)
if file
{
type: :file,
}
else
entries.each do |name, es|
es.each do |e|
e[:ontology] = o
end
end
{
type: :dir,
}
end
else
case
when entries.size == 1
{
type: :file_base,
}
else
{
type: :file_base_ambiguous,
}
end
end
end
end
# given a commit oid or a branch name, commit_id returns a hash of oid and branch name if existent
branch_names = git.branches.select { |b| b[:oid] == oid }
{ oid: oid, branch_name: nil }
else
{ oid: oid, branch_name: branch_names[0][:name] }
end
else
else
end
end
end
end
end
end
result_pull = case source_type
else
raise Repository::ImportError, "unknown source type: #{source_type}"
end
{
success: result_pull[:success] && result_push[:success],
}
end
end
# creates a new repository and imports the contents from the source git repository
def import_from_git(user, source, name, params={})
raise Repository::ImportError, "#{source} is not a git repository" unless GitRepository.is_git_repository? source
params[:source_address] = source
r = Repository.create!(params)
result_wc = GitRepository.clone_git(source, r.local_path_working_copy, false)
unless result_wc[:success] && result_bare[:success] && result_remote_rm[:success] && result_remote_set[:success]
raise Repository::ImportError, 'could not import repository'
end
r
end
# creates a new repository and imports the contents from the source svn repository
def import_from_svn(user, source, name, params={})
raise Repository::ImportError, "#{source} is not an svn repository" unless GitRepository.is_svn_repository? source
params[:source_address] = source
r = Repository.create!(params)
raise Repository::ImportError, 'could not import repository'
end
r
end
end
end