Module: Git::Base::Factory
- Included in:
- Git::Base
- Defined in:
- lib/git/base/factory.rb
Instance Method Summary collapse
-
#branch(branch_name = self.current_branch) ⇒ Git::Branch
An object for branch_name.
-
#branches ⇒ Git::Branches
A collection of all the branches in the repository.
-
#commit_tree(tree = nil, opts = {}) ⇒ Git::Object::Commit
A commit object.
-
#diff(objectish = 'HEAD', obj2 = nil) ⇒ Git::Diff
A Git::Diff object.
-
#gblob(objectish) ⇒ Git::Object
A Git object.
-
#gcommit(objectish) ⇒ Git::Object
A Git object.
-
#gtree(objectish) ⇒ Git::Object
A Git object.
-
#log(count = 30) ⇒ Git::Log
A log with the specified number of commits.
-
#merge_base(*args) ⇒ Array<Git::Object::Commit>
Find as good common ancestors as possible for a merge example: g.merge_base('master', 'some_branch', 'some_sha', octopus: true).
-
#object(objectish) ⇒ Git::Object
returns a Git::Object of the appropriate type you can also call @git.gtree('tree'), but that's just for readability.
-
#remote(remote_name = 'origin') ⇒ Git::Remote
A remote of the specified name.
-
#status ⇒ Git::Status
A status object.
-
#tag(tag_name) ⇒ Git::Object::Tag
A tag object.
-
#worktree(dir, commitish = nil)
returns a Git::Worktree object for dir, commitish.
-
#worktrees
returns a Git::worktrees object of all the Git::Worktrees objects for this repo.
Instance Method Details
#branch(branch_name = self.current_branch) ⇒ Git::Branch
Returns an object for branch_name.
7 8 9 |
# File 'lib/git/base/factory.rb', line 7 def branch(branch_name = self.current_branch) Git::Branch.new(self, branch_name) end |
#branches ⇒ Git::Branches
Returns a collection of all the branches in the repository. Each branch is represented as a Git::Branch.
13 14 15 |
# File 'lib/git/base/factory.rb', line 13 def branches Git::Branches.new(self) end |
#commit_tree(tree = nil, opts = {}) ⇒ Git::Object::Commit
Returns a commit object.
29 30 31 |
# File 'lib/git/base/factory.rb', line 29 def commit_tree(tree = nil, opts = {}) Git::Object::Commit.new(self, self.lib.commit_tree(tree, opts)) end |
#diff(objectish = 'HEAD', obj2 = nil) ⇒ Git::Diff
Returns a Git::Diff object.
34 35 36 |
# File 'lib/git/base/factory.rb', line 34 def diff(objectish = 'HEAD', obj2 = nil) Git::Diff.new(self, objectish, obj2) end |
#gblob(objectish) ⇒ Git::Object
Returns a Git object.
39 40 41 |
# File 'lib/git/base/factory.rb', line 39 def gblob(objectish) Git::Object.new(self, objectish, 'blob') end |
#gcommit(objectish) ⇒ Git::Object
Returns a Git object.
44 45 46 |
# File 'lib/git/base/factory.rb', line 44 def gcommit(objectish) Git::Object.new(self, objectish, 'commit') end |
#gtree(objectish) ⇒ Git::Object
Returns a Git object.
49 50 51 |
# File 'lib/git/base/factory.rb', line 49 def gtree(objectish) Git::Object.new(self, objectish, 'tree') end |
#log(count = 30) ⇒ Git::Log
Returns a log with the specified number of commits.
54 55 56 |
# File 'lib/git/base/factory.rb', line 54 def log(count = 30) Git::Log.new(self, count) end |
#merge_base(*args) ⇒ Array<Git::Object::Commit>
Find as good common ancestors as possible for a merge example: g.merge_base('master', 'some_branch', 'some_sha', octopus: true)
91 92 93 94 |
# File 'lib/git/base/factory.rb', line 91 def merge_base(*args) shas = self.lib.merge_base(*args) shas.map { |sha| gcommit(sha) } end |
#object(objectish) ⇒ Git::Object
returns a Git::Object of the appropriate type you can also call @git.gtree('tree'), but that's just for readability. If you call @git.gtree('HEAD') it will still return a Git::Object::Commit object.
object calls a factory method that will run a rev-parse on the objectish and determine the type of the object and return an appropriate object for that type
68 69 70 |
# File 'lib/git/base/factory.rb', line 68 def object(objectish) Git::Object.new(self, objectish) end |
#remote(remote_name = 'origin') ⇒ Git::Remote
Returns a remote of the specified name.
73 74 75 |
# File 'lib/git/base/factory.rb', line 73 def remote(remote_name = 'origin') Git::Remote.new(self, remote_name) end |
#status ⇒ Git::Status
Returns a status object.
78 79 80 |
# File 'lib/git/base/factory.rb', line 78 def status Git::Status.new(self) end |
#tag(tag_name) ⇒ Git::Object::Tag
Returns a tag object.
83 84 85 |
# File 'lib/git/base/factory.rb', line 83 def tag(tag_name) Git::Object.new(self, tag_name, 'tag', true) end |