Class: Gollum::Git::Repo
- Inherits:
-
Object
- Object
- Gollum::Git::Repo
- Defined in:
- lib/grit_adapter/git_layer_grit.rb
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(id) ⇒ Object
- #commits(start = 'master', max_count = 10, skip = 0) ⇒ Object
- #config ⇒ Object
- #diff(sha1, sha2, path = nil) ⇒ Object
- #git ⇒ Object
- #head ⇒ Object
- #index ⇒ Object
-
#initialize(path, options) ⇒ Repo
constructor
A new instance of Repo.
- #log(commit = 'master', path = nil, options = {}) ⇒ Object
- #lstree(sha, options = {}) ⇒ Object
- #path ⇒ Object
- #update_ref(head, commit_sha) ⇒ Object
Constructor Details
#initialize(path, options) ⇒ Repo
Returns a new instance of Repo.
287 288 289 290 291 292 293 294 295 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 287 def initialize(path, ) begin @repo = Grit::Repo.new(path, ) rescue Grit::InvalidGitRepositoryError raise Gollum::InvalidGitRepositoryError rescue Grit::NoSuchPathError raise Gollum::NoSuchPathError end end |
Class Method Details
.init(path, git_options = {}, repo_options = {}) ⇒ Object
297 298 299 300 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 297 def self.init(path, = {}, = {}) Grit::Repo.init(path, , ) self.new(path, {:is_bare => false}) end |
.init_bare(path, git_options = {}, repo_options = {}) ⇒ Object
302 303 304 305 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 302 def self.(path, = {}, = {}) Grit::Repo.(path, , ) self.new(path, {:is_bare => true}) end |
Instance Method Details
#bare ⇒ Object
307 308 309 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 307 def @repo. end |
#commit(id) ⇒ Object
319 320 321 322 323 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 319 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
325 326 327 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 325 def commits(start = 'master', max_count = 10, skip = 0) @repo.commits(start, max_count, skip).map{|commit| Gollum::Git::Commit.new(commit)} end |
#config ⇒ Object
311 312 313 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 311 def config @repo.config end |
#diff(sha1, sha2, path = nil) ⇒ Object
338 339 340 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 338 def diff(sha1, sha2, path = nil) @repo.diff(sha1, sha2, path) end |
#git ⇒ Object
315 316 317 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 315 def git @git ||= Gollum::Git::Git.new(@repo.git, ) end |
#head ⇒ Object
330 331 332 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 330 def head Gollum::Git::Ref.new(@repo.head) end |
#index ⇒ Object
334 335 336 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 334 def index @index ||= Gollum::Git::Index.new(@repo.index) end |
#log(commit = 'master', path = nil, options = {}) ⇒ Object
342 343 344 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 342 def log(commit = 'master', path = nil, = {}) @repo.log(commit, path, ).map {|grit_commit| Gollum::Git::Commit.new(grit_commit)} end |
#lstree(sha, options = {}) ⇒ Object
346 347 348 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 346 def lstree(sha, = {}) @repo.lstree(sha, ) end |
#path ⇒ Object
350 351 352 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 350 def path @repo.path end |
#update_ref(head, commit_sha) ⇒ Object
354 355 356 |
# File 'lib/grit_adapter/git_layer_grit.rb', line 354 def update_ref(head, commit_sha) @repo.update_ref(head, commit_sha) end |