Skip to content

Commit 0450d72

Browse files
committed
Force also deletes existing branches
1 parent 8064c57 commit 0450d72

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Rakefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,14 @@ def assert_clean_git_status(name)
555555
end
556556
end
557557

558-
def confirm_branch_name(name)
558+
def confirm_branch_name(name, opts={})
559559
return name unless system("git show-branch #{name} > /dev/null 2>&1")
560560

561+
if opts[:force]
562+
`git branch -D #{name}`
563+
return name
564+
end
565+
561566
puts "Branch #{name} already exists, delete? [Y/n] or rename new branch? [r[ename] <name>]"
562567
case input = STDIN.gets.downcase
563568
when /^y/i
@@ -620,7 +625,7 @@ def update_files_in_repos(purpose, suffix='', opts={})
620625
end
621626

622627
each_project_with_common_build(opts) do |name|
623-
branch_name = confirm_branch_name(branch_name)
628+
branch_name = confirm_branch_name(branch_name, opts)
624629
sh "git checkout -b #{branch_name}"
625630

626631
yield name

0 commit comments

Comments
 (0)