Class: Gollum::Git::Repo
- Inherits:
-
Object
- Object
- Gollum::Git::Repo
- Defined in:
- lib/rjgit_adapter/git_layer_rjgit.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Class Method Summary collapse
- .init(path, git_options = {}, repo_options = {}) ⇒ Object
- .init_bare(path, git_options = {}, repo_options = {}) ⇒ Object
Instance Method Summary collapse
- #bare ⇒ Object
- #commit(ref) ⇒ Object
- #commits(ref = nil, max_count = 10, skip = 0) ⇒ Object
- #config ⇒ Object
- #diff(sha1, sha2, path = nil) ⇒ Object
-
#find(sha, type) ⇒ Object
Not required by gollum-lib.
- #git ⇒ Object
- #head ⇒ Object
- #index ⇒ Object
-
#initialize(path, options = {}) ⇒ Repo
constructor
A new instance of Repo.
- #log(ref = 'refs/heads/master', path = nil, options = {}) ⇒ Object
- #lstree(sha, options = {}) ⇒ Object
- #path ⇒ Object
- #update_ref(ref = 'refs/heads/master', commit_sha) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Repo
Returns a new instance of Repo.
339 340 341 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 339 def initialize(path, = {}) @repo = RJGit::Repo.new(path, ) end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
337 338 339 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 337 def repo @repo end |
Class Method Details
.init(path, git_options = {}, repo_options = {}) ⇒ Object
343 344 345 346 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 343 def self.init(path, = {}, = {}) RJGit::Repo.create(path, {:is_bare => false}) self.new(path, {:is_bare => false}) end |
.init_bare(path, git_options = {}, repo_options = {}) ⇒ Object
348 349 350 351 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 348 def self.(path, = {}, = {}) RJGit::Repo.create(path, {:is_bare => true}) self.new(path, {:is_bare => true}) end |
Instance Method Details
#bare ⇒ Object
353 354 355 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 353 def @repo. end |
#commit(ref) ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 365 def commit(ref) ref = Gollum::Git.canonicalize(ref) objectid = @repo.jrepo.resolve(ref) return nil if objectid.nil? id = objectid.name commit = @repo.find(id, :commit) return nil if commit.nil? Gollum::Git::Commit.new(commit) rescue Java::OrgEclipseJgitErrors::RevisionSyntaxException raise Gollum::Git::NoSuchShaFound end |
#commits(ref = nil, max_count = 10, skip = 0) ⇒ Object
377 378 379 380 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 377 def commits(ref = nil, max_count = 10, skip = 0) ref = Gollum::Git.canonicalize(ref) @repo.commits(ref, max_count).map{|commit| Gollum::Git::Commit.new(commit)} end |
#config ⇒ Object
357 358 359 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 357 def config @repo.config end |
#diff(sha1, sha2, path = nil) ⇒ Object
421 422 423 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 421 def diff(sha1, sha2, path = nil) RJGit::Porcelain.diff(@repo, {:old_rev => sha1, :new_rev => sha2, :file_path => path, :patch => true}).map {|d| Diff.new(d)} end |
#find(sha, type) ⇒ Object
Not required by gollum-lib
383 384 385 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 383 def find(sha, type) @repo.find(sha, type) end |
#git ⇒ Object
361 362 363 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 361 def git @git ||= Gollum::Git::Git.new(@repo.git) end |
#head ⇒ Object
388 389 390 391 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 388 def head return nil unless @repo.head Gollum::Git::Ref.new('refs/heads/master', @repo.head) end |
#index ⇒ Object
393 394 395 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 393 def index @index ||= Gollum::Git::Index.new(RJGit::Plumbing::Index.new(@repo)) end |
#log(ref = 'refs/heads/master', path = nil, options = {}) ⇒ Object
397 398 399 400 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 397 def log(ref = 'refs/heads/master', path = nil, = {}) commit = Gollum::Git.canonicalize(commit) git.log(ref, path, ) end |
#lstree(sha, options = {}) ⇒ Object
402 403 404 405 406 407 408 409 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 402 def lstree(sha, ={}) entries = RJGit::Porcelain.ls_tree(@repo.jrepo, nil, @repo.find(sha, :tree), {:recursive => [:recursive]}) entries.map! do |entry| entry[:mode] = entry[:mode].to_s(8) entry[:sha] = entry[:id] entry end end |
#path ⇒ Object
411 412 413 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 411 def path @repo.path end |
#update_ref(ref = 'refs/heads/master', commit_sha) ⇒ Object
415 416 417 418 419 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 415 def update_ref(ref = 'refs/heads/master', commit_sha) ref = Gollum::Git.canonicalize(head) cm = self.commit(commit_sha) @repo.update_ref(cm.commit, true, ref) end |