git_repositories.rb revision 698f9fc237ae6b40972b7d81e6b0efcfc3124ac2
included do
end
end
end
"#{Ontohub::Application.config.git_root}/#{id}"
end
"#{Ontohub::Application.config.git_working_copies_root}/#{id}"
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}/#{Ontology.filename_without_extension(filepath)}"
version = o.versions.build({ :commit_oid => commit_oid, :user => user }, { without_protection: true })
end
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
case source_type
else
raise Repository::ImportError, "unknown source type: #{source_type}"
end
end
end
# creates a new repository and imports the contents from the source git repository
def import_from_git(source, name, params=nil)
raise Repository::ImportError, "#{source} is not a git repository" unless GitRepository.is_git_repository? source
params ||= {}
#params[:source_type] = Repository::SourceTypes::GIT
#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(source, name, params=nil)
raise Repository::ImportError, "#{source} is not an svn repository" unless GitRepository.is_svn_repository? source
params ||= {}
#params[:source_type] = Repository::SourceTypes::SVN
#params[:source_address] = source
r = Repository.create!(params)
raise Repository::ImportError, 'could not import repository'
end
r
end
end
end