release: added trash

This commit is contained in:
rkiel
2017-09-19 22:59:13 -04:00
parent 005d780fc6
commit f866ac6cec
2 changed files with 41 additions and 1 deletions

View File

@@ -9,7 +9,8 @@ module Release
:init,
:major,
:minor,
:patch
:patch,
:trash
].sort
DEFAULT = :help

39
lib/release/trash.rb Normal file
View File

@@ -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