plugins/repositories/rugged_repository.rb in olelo-0.9.13 vs plugins/repositories/rugged_repository.rb in olelo-0.9.14
- old
+ new
@@ -19,11 +19,11 @@
def filemode
0100644
end
def save
- Rugged::Blob.create(@git, @content)
+ @git.write(@content, :blob)
end
end
class Reference
attr_reader :filemode, :type
@@ -150,23 +150,17 @@
def commit(comment)
raise 'Concurrent transactions' if @head != current_head
user = User.current
author = {email: user.email, name: user.name, time: Time.now }
- commit = Rugged::Commit.create(@git,
- author: author,
- message: comment,
- committer: author,
- parents: [@head],
- tree: @tree.save)
-
- raise 'Concurrent transactions' if @head != current_head
- if current_head
- @git.head.target = commit
- else
- Rugged::Reference.create(@git, "refs/heads/master", commit)
- end
+ Rugged::Commit.create(@git,
+ author: author,
+ message: comment,
+ committer: author,
+ parents: [@head],
+ tree: @tree.save,
+ update_ref: 'HEAD')
end
private
def current_head
@@ -175,11 +169,11 @@
end
def initialize(config)
@git = Rugged::Repository.new(config[:path])
Olelo.logger.info "Opening git repository: #{config[:path]}"
- rescue Rugged::OSError
+ rescue IOError
Olelo.logger.info "Creating git repository: #{config[:path]}"
FileUtils.mkpath(config[:path])
@git = Rugged::Repository.init_at(config[:path], config[:bare])
end
@@ -417,17 +411,17 @@
end
def oid_by_path(commit, path)
return commit.tree_oid if path.blank?
commit.tree.path(path)[:oid]
- rescue Rugged::IndexerError
+ rescue Rugged::Error
nil
end
def object_by_path(commit, path)
return commit.tree if path.blank?
@git.lookup(commit.tree.path(path)[:oid])
- rescue Rugged::IndexerError
+ rescue Rugged::Error
nil
end
def commit_to_version(commit)
commit && Version.new(commit.oid, User.new(commit.author[:name], commit.author[:email]),