Class: Toolshed::Commands::CreateBranch
- Inherits:
-
Object
- Object
- Toolshed::Commands::CreateBranch
- Defined in:
- lib/toolshed/commands/create_branch.rb
Instance Method Summary collapse
- #execute(args, options = {}) ⇒ Object
- #read_user_input_branch_from(message, options) ⇒ Object
- #read_user_input_branch_name(message, options) ⇒ Object
Instance Method Details
#execute(args, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/toolshed/commands/create_branch.rb', line 4 def execute(args, = {}) begin branch_name = read_user_input_branch_name("Branch name:", ) branch_from = read_user_input_branch_from("Branch from:", ) puts "Branch name: #{branch_name}" puts "Branching from: #{branch_from}" git = Toolshed::Git::Base.new({ from_remote_branch_name: branch_from, to_remote_branch_name: branch_name, }) git.create_branch puts "Branch #{branch_name} has been created" return rescue Veto::InvalidEntity => e puts "Unable to create branch due to the following errors" e..each do |key, value| puts "#{key}: #{value}" end return end end |
#read_user_input_branch_from(message, options) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/toolshed/commands/create_branch.rb', line 44 def read_user_input_branch_from(, ) return [:branch_from] if (.has_key?(:branch_from)) # if branch-name was supplied then default to master if not supplied if (.has_key?(:branch_name)) return Toolshed::Git::DEFAULT_BRANCH_FROM end puts value = $stdin.gets.chomp until (!value.empty?) puts "Branch from cannot be empty" puts value = $stdin.gets.chomp end value end |
#read_user_input_branch_name(message, options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/toolshed/commands/create_branch.rb', line 29 def read_user_input_branch_name(, ) return [:branch_name] if (.has_key?(:branch_name)) puts value = $stdin.gets.chomp until (!value.empty?) puts "Branch name cannot be empty" puts value = $stdin.gets.chomp end value end |