git_repositories.rb revision 658151642f71e0593b7d55f124fd42ebe2cfcf9a
require 'git_repository'
included do
end
end
end
# replace capistrano-style release with 'current'-symlink
end
end
end
end
message ||= "delete file #{filepath}"
end
end
end
end
end
def save_ontology(commit_oid, filepath, user=nil, iri: nil, fast_parse: false, do_not_parse: false, previous_filepath: nil)
# we expect that this method is only called, when the ontology is 'present'
if o
o.present = true
# update existing ontology
fast_parse: fast_parse },
{ without_protection: true })
end
else
# create new ontology
clazz = Ontology.file_extensions_distributed.include?(File.extname(filepath)) ? DistributedOntology : SingleOntology
o = clazz.new
o.iri = iri || generate_iri(basepath)
o.present = true
fast_parse: fast_parse },
{ without_protection: true })
end
end
path ||= '/'
end
end
path ||= '/'
if git.empty?
end
if path_exists?(path, commit_oid)
if file
{
type: :file,
}
else
entries.each do |name, es|
es.each do |e|
end
es.sort_by! { |e| -e[:ontologies].size }
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
commits(limit: 3)
end
versions = []
if f.added? || f.modified?
versions << save_ontology(commit.oid, f.path, options.delete(:user), fast_parse: has_changed?(f.path, commit.oid), do_not_parse: true)
elsif f.renamed?
versions << save_ontology(commit.oid, f.path, options.delete(:user), fast_parse: has_changed?(f.path, commit.oid), do_not_parse: true, previous_filepath: f.delta.old_file[:path])
end
}
}
schedule_batch_parsing(versions)
end
def schedule_batch_parsing(versions)
grouped_versions = versions.compact.group_by { |v| v.path }
grouped_versions.each do |k,versions|
optioned_versions = versions.map do |version|
[version.id, { fast_parse: version.fast_parse }]
end
OntologyBatchParseWorker.perform_async(optioned_versions)
end
end
def user_info(user)
{email: user.email, name: user.name}
end
def master_file?(ontology, filepath)
ontology.path == filepath
end
def generate_iri(basepath)
"http://#{Settings.hostname}/#{self.path}/#{basepath}"
end
end