Class: HustleAndFlow::VersionControls::Git::Branch
- Inherits:
-
Object
- Object
- HustleAndFlow::VersionControls::Git::Branch
- Defined in:
- lib/hustle_and_flow/version_controls/git/branch.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
- #author ⇒ Object
- #current? ⇒ Boolean
- #has_tracking_branch? ⇒ Boolean
-
#initialize(repo:, branch:) ⇒ Branch
constructor
A new instance of Branch.
- #local? ⇒ Boolean
- #name ⇒ Object
- #remote? ⇒ Boolean
- #start ⇒ Object
- #version_number ⇒ Object
Constructor Details
#initialize(repo:, branch:) ⇒ Branch
Returns a new instance of Branch.
8 9 10 11 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 8 def initialize(repo:, branch:) self.repo = repo self.branch = branch end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
5 6 7 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 5 def branch @branch end |
#repo ⇒ Object
Returns the value of attribute repo.
5 6 7 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 5 def repo @repo end |
Instance Method Details
#author ⇒ Object
29 30 31 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 29 def latest_commit..name end |
#current? ⇒ Boolean
13 14 15 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 13 def current? local? && branch.current end |
#has_tracking_branch? ⇒ Boolean
25 26 27 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 25 def has_tracking_branch? local? && upstream end |
#local? ⇒ Boolean
17 18 19 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 17 def local? !remote? end |
#name ⇒ Object
33 34 35 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 33 def name branch.name end |
#remote? ⇒ Boolean
21 22 23 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 21 def remote? !branch.remote.to_s.empty? end |
#start ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 37 def start # WIP if necessary repo.with_branch(name) do ensure_upstream end # if selected_branch.has_wip_commit? && yes?("There is a WIP commit on this bra # nch, would you like to apply it locally?") # repo.rollback # # say "The WIP commit has been applied." # # if yes?("Would you like to remove the commit from origin?") # repo.push(branch: selected_branch, force: true) # end # end end |
#version_number ⇒ Object
56 57 58 |
# File 'lib/hustle_and_flow/version_controls/git/branch.rb', line 56 def version_number name[/v(\d+)\z/, 1].to_i end |