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
- #find_or_create_branch(branch_name) ⇒ Object
-
#initialize(path:) ⇒ Repository
constructor
A new instance of Repository.
- #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
17 18 19 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 17 def base_name origin_url[%r{github\.com.([\w\-]+/[\w\-]+)}, 1] end |
#branches ⇒ Object
45 46 47 48 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 45 def branches Branches.new(repo: self, branches: repo.branches) end |
#find_or_create_branch(branch_name) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 37 def find_or_create_branch(branch_name) new_branch = repo.branch(branch_name) new_branch.checkout Branch.new(repo: self, branch: new_branch) end |
#upstream_branch_for_branch(branch_name, value = nil) ⇒ Object
25 26 27 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 25 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
21 22 23 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 21 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
29 30 31 32 33 34 35 |
# File 'lib/hustle_and_flow/version_controls/git/repository.rb', line 29 def with_branch(branch_name) repo.checkout(branch_name) yield repo.push('origin', branch_name) end |