@@ -203,7 +203,7 @@ namespace :git do
203
203
sh "git add ."
204
204
sh "git ci -m 'Update version to #{ version } '"
205
205
end
206
- force_update ( branch , nil )
206
+ force_update ( branch , nil , false )
207
207
end
208
208
209
209
{ :show => nil , :status => nil , :reset => '--hard' , :diff => nil } . each do |command , options |
@@ -386,9 +386,9 @@ namespace :ci do
386
386
end
387
387
388
388
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 |
390
390
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 )
392
392
end
393
393
end
394
394
@@ -465,8 +465,8 @@ namespace :common_plaintext_files do
465
465
end
466
466
467
467
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" )
470
470
end
471
471
end
472
472
@@ -557,12 +557,16 @@ def each_project_with_common_build(opts={}, &b)
557
557
each_project ( :except => except , &b )
558
558
end
559
559
560
- def force_update ( branch , custom_pr_comment , opts = { } )
560
+ def force_update ( branch , custom_pr_comment , skip_confirmation = false , opts = { } )
561
561
each_project_with_common_build ( opts ) do |name |
562
562
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
566
570
end
567
571
create_pull_request ( name , branch , custom_pr_comment ) rescue nil
568
572
else
0 commit comments