class Gollum::Git::Repo
Public Class Methods
init(path)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 550 def self.init(path) Rugged::Repository.init_at(path, false) self.new(path, :is_bare => false) end
init_bare(path)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 555 def self.init_bare(path) Rugged::Repository.init_at(path, true) self.new(path, :is_bare => true) end
new(path, options)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 540 def initialize(path, options) begin @repo = Rugged::Repository.new(path, options) #rescue Grit::InvalidGitRepositoryError # raise Gollum::InvalidGitRepositoryError #rescue Grit::NoSuchPathError # raise Gollum::NoSuchPathError end end
Public Instance Methods
bare()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 560 def bare @repo.bare? end
commit(id)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 572 def commit(id) git.commit_from_ref(id) end
commits(start = 'refs/heads/master', max_count = 10, skip = 0)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 576 def commits(start = 'refs/heads/master', max_count = 10, skip = 0) git.log(start, nil, :max_count => max_count, :skip => skip) end
config()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 564 def config @repo.config end
diff(sha1, sha2, *paths)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 588 def diff(sha1, sha2, *paths) opts = path == nil ? {} : {:path => path} patches = @repo.diff(sha1, sha2, opts).patches if not paths.empty? patches.keep_if { |p| paths.include? p.delta.new_file[:path] } end patches.map {|patch| OpenStruct.new(:diff => patch.to_s.split("\n")[2..-1].join("\n").force_encoding("UTF-8"))}.reverse # First remove two superfluous lines. Rugged seems to order the diffs differently than Grit, so reverse. end
git()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 568 def git @git ||= Gollum::Git::Git.new(@repo) end
head()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 580 def head Gollum::Git::Ref.new(@repo.head) end
index()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 584 def index @index ||= Gollum::Git::Index.new(@repo.index, @repo) end
log(commit = 'refs/heads/master', path = nil, options = {})
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 597 def log(commit = 'refs/heads/master', path = nil, options = {}) git.log(commit, path, options) end
lstree(sha, options = {})
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 601 def lstree(sha, options = {}) results = [] @repo.lookup(sha).tree.walk(:postorder) do |root, entry| entry[:sha] = entry[:oid] entry[:mode] = entry[:filemode].to_s(8) entry[:type] = entry[:type].to_s entry[:path] = "#{root}#{entry[:name]}" results << entry end results end
path()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 613 def path @repo.path end
update_ref(ref, commit_sha)
click to toggle source
Checkout branch and if necessary first create it. Currently used only in gollum-lib's tests.
# File lib/rugged_adapter/git_layer_rugged.rb, line 618 def update_ref(ref, commit_sha) ref = "refs/heads/#{ref}" unless ref =~ /^refs\/heads\// if _ref = @repo.references[ref] @repo.references.update(_ref, commit_sha) else @repo.create_branch(ref, commit_sha) @repo.checkout(ref, :strategy => :force) unless @repo.bare? end end