class Dude::Git::Checkout

Attributes

branch_name[R]

Public Instance Methods

call(branch_name) click to toggle source
# File lib/dude/git/checkout.rb, line 6
def call(branch_name)
  @branch_name = branch_name
  branch_exists? ? checkout_on_exising_branch : checkout_and_create
end

Private Instance Methods

branch_exists?() click to toggle source
# File lib/dude/git/checkout.rb, line 15
def branch_exists?
  !`git show-ref refs/heads/#{branch_name}`.empty?
end
checkout_and_create() click to toggle source
# File lib/dude/git/checkout.rb, line 19
def checkout_and_create
  `git checkout -b #{branch_name}`
end
checkout_on_exising_branch() click to toggle source
# File lib/dude/git/checkout.rb, line 23
def checkout_on_exising_branch
  `git checkout #{branch_name}`
end