Class: AppCommand::GitDelete
- Inherits:
-
Convoy::ActionCommand::Base
- Object
- Convoy::ActionCommand::Base
- AppCommand::GitDelete
- Defined in:
- lib/routes/git_delete.rb
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/routes/git_delete.rb', line 5 def execute @opts = @args = arguments @git = App::Git.new opts_validate opts_routing end |
#opts_routing ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/routes/git_delete.rb', line 37 def opts_routing branch_to_delete = @args[0] if branch_to_delete =~ /\A\d{4,5}\z/i branch_to_delete = @git.resolve_branch_for_jira(branch_to_delete) end if @opts[:delete_local] App::GitDelete::delete_local(branch_to_delete) elsif @opts[:delete_remote] App::GitDelete::delete_remote(branch_to_delete) elsif @opts[:delete_both] App::GitDelete::delete_both(branch_to_delete) end end |
#opts_validate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/routes/git_delete.rb', line 15 def opts_validate if @opts[:delete_local] == false && @opts[:delete_remote] == false && @opts[:delete_both] == false App::Terminal::error('You must specify one of the following flags:', [ "-l --delete-local \xe2\x86\x92 Delete local branch", "-r --delete-remote \xe2\x86\x92 Delete remote branch", "-b --delete-both \xe2\x86\x92 Delete both local & remote branches" ], true) end unless @args.any? @args[0] = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)) end if @args[0] == 'master' puts "You cannot delete \x1B[32m[master]\x1B[0m" exit end end |