plugins/repositories/rugged_repository.rb in olelo-0.9.8 vs plugins/repositories/rugged_repository.rb in olelo-0.9.9

- old
+ new

@@ -225,10 +225,11 @@ work_tree.move(path + ATTRIBUTE_EXT, destination + ATTRIBUTE_EXT) if work_tree[path + ATTRIBUTE_EXT] collapse_empty_tree(path/'..') end def delete(path) + check_path(path) work_tree.delete(path) work_tree.delete(path + CONTENT_EXT) if work_tree[path + CONTENT_EXT] work_tree.delete(path + ATTRIBUTE_EXT) if work_tree[path + ATTRIBUTE_EXT] collapse_empty_tree(path/'..') end @@ -237,10 +238,11 @@ current_transaction.commit(comment) commit_to_version(@git.last_commit) end def path_etag(path, version) + check_path(path) commit = @git.lookup(version.to_s) raise 'Not a commit' unless Rugged::Commit === commit if oid = oid_by_path(commit, path) [oid, oid_by_path(commit, path + CONTENT_EXT), @@ -256,10 +258,12 @@ commit_to_version(@git.last_commit) rescue nil end end def get_history(path, skip, limit) + check_path(path) + commits = [] walker = Rugged::Walker.new(@git) walker.sorting(Rugged::SORT_TOPO) walker.push(@git.head.target) walker.each do |c| @@ -274,10 +278,12 @@ end commits.map {|c| commit_to_version(c) } end def get_path_version(path, version) + check_path(path) + version ||= @git.head.target version = version.to_s commits = [] walker = Rugged::Walker.new(@git) @@ -311,34 +317,38 @@ commit_to_version(commits[0]), # current version commit_to_version(succ)] # next version end def get_children(path, version) + check_path(path) commit = @git.lookup(version.to_s) raise 'Not a commit' unless Rugged::Commit === commit object = object_by_path(commit, path) Rugged::Tree === object ? object.map do |e| e[:name].force_encoding(Encoding.default_external) end.reject {|name| reserved_name?(name) } : [] end def get_content(path, version) + check_path(path) commit = @git.lookup(version.to_s) raise 'Not a commit' unless Rugged::Commit === commit object = object_by_path(commit, path) object = object_by_path(commit, path + CONTENT_EXT) if Rugged::Tree === object Rugged::Blob === object ? object.content.try_encoding(Encoding.default_external) : '' end def get_attributes(path, version) + check_path(path) commit = @git.lookup(version.to_s) raise 'Not a commit' unless Rugged::Commit === commit path += ATTRIBUTE_EXT object = object_by_path(commit, path) object ? YAML.load(object.content) : {} end def diff(path, from, to) + check_path(path) commit_from = from && @git.rev_parse(from.to_s) commit_to = @git.rev_parse(to.to_s) raise 'Not a commit' unless (!commit_from || Rugged::Commit === commit_from) && Rugged::Commit === commit_to diff = git_diff_tree('--root', '--full-index', '-u', '-M', commit_from ? commit_from.oid : nil, commit_to.oid, '--', path, path + CONTENT_EXT, path + ATTRIBUTE_EXT) Diff.new(commit_to_version(commit_from), commit_to_version(commit_to), diff)