Class: HustleAndFlow::VersionControls::Git::Repository
- Inherits:
-
Object
- Object
- HustleAndFlow::VersionControls::Git::Repository
- Defined in:
- lib/hustle_and_flow/version_controls/git/repository.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
- #base_name ⇒ Object
- #branches ⇒ Object
- #current_branch ⇒ Object
- #find_or_create_branch(branch_name) ⇒ Object
-
#initialize(path:) ⇒ Repository
constructor
A new instance of Repository.
- #organization ⇒ Object
- #upstream_branch_for_branch(branch_name, value = nil) ⇒ Object
- #upstream_remote_for_branch(branch_name, value = nil) ⇒ Object
- #user ⇒ Object
- #with_branch(branch_name) ⇒ Object
Constructor Details
#initialize(path:) ⇒ Repository
Returns a new instance of Repository.
9 10 11 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 9 def initialize(path:) self.repo = ::Git.open(path) end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
7 8 9 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 7 def repo @repo end |
Instance Method Details
#base_name ⇒ Object
21 22 23 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 21 def base_name repo_name_parts.join('/') end |
#branches ⇒ Object
49 50 51 52 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 49 def branches Branches.new(repo: self, branches: repo.branches) end |
#current_branch ⇒ Object
54 55 56 57 58 59 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 54 def current_branch current = repo.branch(repo.current_branch) Branch.new(repo: self, branch: current) end |
#find_or_create_branch(branch_name) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 41 def find_or_create_branch(branch_name) new_branch = repo.branch(branch_name) new_branch.checkout Branch.new(repo: self, branch: new_branch) end |
#organization ⇒ Object
17 18 19 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 17 def organization repo_name_parts[0] end |
#upstream_branch_for_branch(branch_name, value = nil) ⇒ Object
29 30 31 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 29 def upstream_branch_for_branch(branch_name, value = nil) repo.config(upstream_merge_config_key(branch_name), value) end |
#upstream_remote_for_branch(branch_name, value = nil) ⇒ Object
25 26 27 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 25 def upstream_remote_for_branch(branch_name, value = nil) repo.config(upstream_remote_config_key(branch_name), value) end |
#user ⇒ Object
13 14 15 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 13 def user repo.config('github.user') end |
#with_branch(branch_name) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 33 def with_branch(branch_name) repo.checkout(branch_name) yield repo.push('origin', branch_name) end |