trash: added safety feature trash
This commit is contained in:
@@ -4,19 +4,27 @@ module Feature
|
|||||||
|
|
||||||
class Trash < Feature::Base
|
class Trash < Feature::Base
|
||||||
def valid?
|
def valid?
|
||||||
argv.size == 1
|
argv.size == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
def help
|
def help
|
||||||
"feature trash"
|
"feature trash confirmation-branch"
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
parts = parse_branch(current_branch)
|
parts = parse_branch(current_branch)
|
||||||
|
|
||||||
|
if argv.size == 2
|
||||||
|
confirmation_branch = argv[1]
|
||||||
|
else
|
||||||
|
confirmation_branch = ''
|
||||||
|
end
|
||||||
|
|
||||||
standard_branch = parts[:standard]
|
standard_branch = parts[:standard]
|
||||||
feature_branch = current_branch
|
feature_branch = current_branch
|
||||||
|
|
||||||
|
error "missing confirmation of branch: #{feature_branch}" if confirmation_branch == ''
|
||||||
|
error "confirmation branch does not match current branch: #{confirmation_branch} vs #{feature_branch}" if feature_branch != confirmation_branch
|
||||||
error "invalid feature branch: #{feature_branch}" if standard_branches.include? feature_branch
|
error "invalid feature branch: #{feature_branch}" if standard_branches.include? feature_branch
|
||||||
|
|
||||||
git_checkout standard_branch
|
git_checkout standard_branch
|
||||||
|
|||||||
Reference in New Issue
Block a user