diff --git a/lib/release/commander.rb b/lib/release/commander.rb index 2c4f888..34b8ef2 100644 --- a/lib/release/commander.rb +++ b/lib/release/commander.rb @@ -9,7 +9,8 @@ module Release :init, :major, :minor, - :patch + :patch, + :trash ].sort DEFAULT = :help diff --git a/lib/release/trash.rb b/lib/release/trash.rb new file mode 100644 index 0000000..a3e8941 --- /dev/null +++ b/lib/release/trash.rb @@ -0,0 +1,39 @@ +require_relative './base' + +module Release + + class Trash < Release::Base + def valid? + argv.size == 2 + end + + def help + "release trash local-branch-confirmation" + end + + def execute + if argv.size == 2 + confirmation_branch = argv[1] + else + confirmation_branch = '' + end + + release_branch = current_branch + + error "missing confirmation of branch: #{release_branch}" if confirmation_branch == '' + error "confirmation branch does not match current branch: #{confirmation_branch} vs #{release_branch}" if release_branch != confirmation_branch + error "invalid release branch: #{release_branch}" unless current_branch =~ /\d+\.\d+\.\d+/ + + git_checkout 'master' + + git_local_branch_trash release_branch + + if remote_branch(release_branch) != "" + git_remote_branch_delete release_branch + end + + git_prune + end + end + +end