Skip to content

Commit 3273c0c

Browse files
committed
Allow branch update tasks to force without asking
1 parent 93baba0 commit 3273c0c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Rakefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ namespace :git do
203203
sh "git add ."
204204
sh "git ci -m 'Update version to #{version}'"
205205
end
206-
force_update(branch, nil)
206+
force_update(branch, nil, false)
207207
end
208208

209209
{ :show => nil, :status => nil, :reset => '--hard', :diff => nil }.each do |command, options|
@@ -386,9 +386,9 @@ namespace :ci do
386386
end
387387

388388
desc "Updates the CI files and creates a PR"
389-
task :create_pr_with_updates, :custom_pr_comment do |t, args|
389+
task :create_pr_with_updates, :custom_pr_comment, :force do |t, args|
390390
opts = { except: %w[ rspec-rails ] }
391-
force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], opts)
391+
force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], args[:force] == "force", opts)
392392
end
393393
end
394394

@@ -465,8 +465,8 @@ namespace :common_plaintext_files do
465465
end
466466

467467
desc "Updates the common plaintext files files and creates a PR"
468-
task :create_pr_with_updates, :custom_pr_comment do |_t, args|
469-
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment])
468+
task :create_pr_with_updates, :custom_pr_comment, :force do |_t, args|
469+
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment], args[:force] == "force")
470470
end
471471
end
472472

@@ -557,12 +557,16 @@ def each_project_with_common_build(opts={}, &b)
557557
each_project(:except => except, &b)
558558
end
559559

560-
def force_update(branch, custom_pr_comment, opts={})
560+
def force_update(branch, custom_pr_comment, skip_confirmation=false, opts={})
561561
each_project_with_common_build(opts) do |name|
562562
unless system("git push origin #{branch}")
563-
puts "Push failed, force? (y/n)"
564-
if STDIN.gets.downcase =~ /^y/
565-
sh "git push origin +#{branch}"
563+
if skip_confirmation
564+
sh "git push origin #{branch} --force-with-lease"
565+
else
566+
puts "Push failed, force? (y/n)"
567+
if STDIN.gets.downcase =~ /^y/
568+
sh "git push origin +#{branch}"
569+
end
566570
end
567571
create_pull_request(name, branch, custom_pr_comment) rescue nil
568572
else

0 commit comments

Comments
 (0)