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.
343 344 345 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 343 def initialize(path, = {}) @repo = RJGit::Repo.new(path, ) end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
341 342 343 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 341 def repo @repo end |
Class Method Details
.init(path, git_options = {}, repo_options = {}) ⇒ Object
347 348 349 350 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 347 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
352 353 354 355 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 352 def self.(path, = {}, = {}) RJGit::Repo.create(path, {:is_bare => true}) self.new(path, {:is_bare => true}) end |
Instance Method Details
#bare ⇒ Object
357 358 359 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 357 def @repo. end |
#commit(ref) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 369 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
381 382 383 384 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 381 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
361 362 363 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 361 def config @repo.config end |
#diff(sha1, sha2, path = nil) ⇒ Object
425 426 427 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 425 def diff(sha1, sha2, path = nil) RJGit::Porcelain.diff(@repo, {:old_rev => sha1, :new_rev => sha2, :file_path => path, :patch => true}).inject("") {|result, diff| result << diff[:patch]} end |
#find(sha, type) ⇒ Object
Not required by gollum-lib
387 388 389 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 387 def find(sha, type) @repo.find(sha, type) end |
#git ⇒ Object
365 366 367 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 365 def git @git ||= Gollum::Git::Git.new(@repo.git) end |
#head ⇒ Object
392 393 394 395 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 392 def head return nil unless @repo.head Gollum::Git::Ref.new('refs/heads/master', @repo.head) end |
#index ⇒ Object
397 398 399 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 397 def index @index ||= Gollum::Git::Index.new(RJGit::Plumbing::Index.new(@repo)) end |
#log(ref = 'refs/heads/master', path = nil, options = {}) ⇒ Object
401 402 403 404 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 401 def log(ref = 'refs/heads/master', path = nil, = {}) commit = Gollum::Git.canonicalize(commit) git.log(ref, path, ) end |
#lstree(sha, options = {}) ⇒ Object
406 407 408 409 410 411 412 413 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 406 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
415 416 417 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 415 def path @repo.path end |
#update_ref(ref = 'refs/heads/master', commit_sha) ⇒ Object
419 420 421 422 423 |
# File 'lib/rjgit_adapter/git_layer_rjgit.rb', line 419 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 |