Class: EasyAuto::CreateBranch
- Inherits:
-
Object
- Object
- EasyAuto::CreateBranch
- Includes:
- EasyUtilities, GitWrapper
- Defined in:
- lib/easy_auto/create_branch.rb
Instance Attribute Summary collapse
-
#new_branch ⇒ Object
readonly
Returns the value of attribute new_branch.
-
#origin_branch ⇒ Object
readonly
Returns the value of attribute origin_branch.
Instance Method Summary collapse
- #checkout_master ⇒ Object
- #help_request? ⇒ Boolean
-
#initialize(new_branch = nil, origin_branch = nil) ⇒ CreateBranch
constructor
A new instance of CreateBranch.
- #new_branch_message ⇒ Object
- #pull ⇒ Object
- #run ⇒ Object
- #set_upstream ⇒ Object
- #usage ⇒ Object
- #wrong_usage ⇒ Object
Methods included from EasyUtilities
Methods included from GitWrapper
Constructor Details
#initialize(new_branch = nil, origin_branch = nil) ⇒ CreateBranch
Returns a new instance of CreateBranch.
12 13 14 15 |
# File 'lib/easy_auto/create_branch.rb', line 12 def initialize new_branch = nil, origin_branch = nil @new_branch = new_branch @origin_branch = origin_branch end |
Instance Attribute Details
#new_branch ⇒ Object (readonly)
Returns the value of attribute new_branch.
9 10 11 |
# File 'lib/easy_auto/create_branch.rb', line 9 def new_branch @new_branch end |
#origin_branch ⇒ Object (readonly)
Returns the value of attribute origin_branch.
10 11 12 |
# File 'lib/easy_auto/create_branch.rb', line 10 def origin_branch @origin_branch end |
Instance Method Details
#checkout_master ⇒ Object
37 38 39 |
# File 'lib/easy_auto/create_branch.rb', line 37 def checkout_master git.checkout_master end |
#help_request? ⇒ Boolean
29 30 31 |
# File 'lib/easy_auto/create_branch.rb', line 29 def help_request? %w{-h --help}.include? new_branch end |
#new_branch_message ⇒ Object
49 50 51 |
# File 'lib/easy_auto/create_branch.rb', line 49 def puts "successfully created branch and set upstream remote!" end |
#pull ⇒ Object
41 42 43 |
# File 'lib/easy_auto/create_branch.rb', line 41 def pull git.pull end |
#run ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/easy_auto/create_branch.rb', line 17 def run return usage if wrong_usage || help_request? checkout_master pull git.create_and_switch_to new_branch, origin_branch if set_upstream end |
#set_upstream ⇒ Object
45 46 47 |
# File 'lib/easy_auto/create_branch.rb', line 45 def set_upstream SetUpstream.new(new_branch).set end |
#usage ⇒ Object
33 34 35 |
# File 'lib/easy_auto/create_branch.rb', line 33 def usage puts 'usage: create-branch <new-branch> <OPTIONAL: branch-to-track>.' end |
#wrong_usage ⇒ Object
25 26 27 |
# File 'lib/easy_auto/create_branch.rb', line 25 def wrong_usage [new_branch, origin_branch].all?(&:nil?) end |