Class: Gollum::Git::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/grit_adapter/git_layer_grit.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options) ⇒ Repo

Returns a new instance of Repo.



285
286
287
288
289
290
291
292
293
# File 'lib/grit_adapter/git_layer_grit.rb', line 285

def initialize(path, options)
  begin
    @repo = Grit::Repo.new(path, options)
  rescue Grit::InvalidGitRepositoryError
    raise Gollum::InvalidGitRepositoryError
  rescue Grit::NoSuchPathError
    raise Gollum::NoSuchPathError
  end
end

Class Method Details

.init(path, git_options = {}, repo_options = {}) ⇒ Object



295
296
297
298
# File 'lib/grit_adapter/git_layer_grit.rb', line 295

def self.init(path, git_options = {}, repo_options = {})
  Grit::Repo.init(path, git_options, repo_options)
  self.new(path, {:is_bare => false})
end

.init_bare(path, git_options = {}, repo_options = {}) ⇒ Object



300
301
302
303
# File 'lib/grit_adapter/git_layer_grit.rb', line 300

def self.init_bare(path, git_options = {}, repo_options = {})
  Grit::Repo.init_bare(path, git_options, repo_options)
  self.new(path, {:is_bare => true})
end

Instance Method Details

#bareObject



305
306
307
# File 'lib/grit_adapter/git_layer_grit.rb', line 305

def bare
  @repo.bare
end

#commit(id) ⇒ Object



317
318
319
320
321
# File 'lib/grit_adapter/git_layer_grit.rb', line 317

def commit(id)
  commit = @repo.commit(id)
  return nil if commit.nil?
  Gollum::Git::Commit.new(@repo.commit(id))
end

#commits(start = 'master', max_count = 10, skip = 0) ⇒ Object



323
324
325
# File 'lib/grit_adapter/git_layer_grit.rb', line 323

def commits(start = 'master', max_count = 10, skip = 0)
  @repo.commits(start, max_count, skip).map{|commit| Gollum::Git::Commit.new(commit)}
end

#configObject



309
310
311
# File 'lib/grit_adapter/git_layer_grit.rb', line 309

def config
  @repo.config
end

#diff(sha1, sha2, path = nil) ⇒ Object



336
337
338
# File 'lib/grit_adapter/git_layer_grit.rb', line 336

def diff(sha1, sha2, path = nil)
  @repo.diff(sha1, sha2, path)
end

#gitObject



313
314
315
# File 'lib/grit_adapter/git_layer_grit.rb', line 313

def git
  @git ||= Gollum::Git::Git.new(@repo.git, bare)
end

#headObject



328
329
330
# File 'lib/grit_adapter/git_layer_grit.rb', line 328

def head
  Gollum::Git::Ref.new(@repo.head)
end

#indexObject



332
333
334
# File 'lib/grit_adapter/git_layer_grit.rb', line 332

def index
  @index ||= Gollum::Git::Index.new(@repo.index)
end

#log(commit = 'master', path = nil, options = {}) ⇒ Object



340
341
342
# File 'lib/grit_adapter/git_layer_grit.rb', line 340

def log(commit = 'master', path = nil, options = {})
  @repo.log(commit, path, options).map {|grit_commit| Gollum::Git::Commit.new(grit_commit)}
end

#lstree(sha, options = {}) ⇒ Object



344
345
346
# File 'lib/grit_adapter/git_layer_grit.rb', line 344

def lstree(sha, options = {})
  @repo.lstree(sha, options)
end

#pathObject



348
349
350
# File 'lib/grit_adapter/git_layer_grit.rb', line 348

def path
  @repo.path
end

#update_ref(head, commit_sha) ⇒ Object



352
353
354
# File 'lib/grit_adapter/git_layer_grit.rb', line 352

def update_ref(head, commit_sha)
  @repo.update_ref(head, commit_sha)
end