Skip to content

Commit ebc5d6f

Browse files
committed
Allow branch update tasks to force without asking
1 parent d5c2c35 commit ebc5d6f

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|
@@ -387,9 +387,9 @@ namespace :ci do
387387
end
388388

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

@@ -466,8 +466,8 @@ namespace :common_plaintext_files do
466466
end
467467

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

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

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

0 commit comments

Comments
 (0)