Class: Toolshed::Commands::CheckoutGitBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/commands/checkout_git_branch.rb

Instance Method Summary collapse

Instance Method Details

#execute(args, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/toolshed/commands/checkout_git_branch.rb', line 4

def execute(args, options = {})
  print "Ticket ID or Branch Name? "
  ticket_id = $stdin.gets.chomp

  branch_name = `git branch | grep \"#{ticket_id}\"`.gsub("*", "").strip

  git_submodule_command = ''
  if (Toolshed::Client.use_git_submodules)
    print "Update Submodules (y/n)? "
    update_submodules = $stdin.gets.chomp
    if (update_submodules == 'y')
      git_submodule_command = "git submodule update --init;"
    end
  end

  system("git checkout #{branch_name}; #{git_submodule_command}")
end