@@ -224,7 +224,7 @@ namespace :git do
224
224
desc 'git push on all the repos'
225
225
task :push , :force do |t , args |
226
226
branch = `git rev-parse --abbrev-ref HEAD`
227
- if args [ :force ]
227
+ if should_force? ( args )
228
228
run_command "git push origin #{ branch } --force-with-lease"
229
229
else
230
230
run_command "git push origin #{ branch } "
@@ -396,8 +396,8 @@ namespace :ci do
396
396
397
397
desc "Updates the CI files and creates a PR"
398
398
task :create_pr_with_updates , :custom_pr_comment , :force do |t , args |
399
- opts = { except : %w[ rspec-rails ] }
400
- force_update ( update_ci_files_in_repos ( opts ) , args [ :custom_pr_comment ] , args [ :force ] == "force" , opts )
399
+ opts = { except : %w[ rspec-rails ] , force : should_force? ( args ) }
400
+ force_update ( update_ci_files_in_repos ( opts ) , args [ :custom_pr_comment ] , opts [ :force ] , opts )
401
401
end
402
402
end
403
403
@@ -488,7 +488,7 @@ namespace :common_plaintext_files do
488
488
489
489
desc "Updates the common plaintext files files and creates a PR"
490
490
task :create_pr_with_updates , :custom_pr_comment , :force do |_t , args |
491
- force_update ( update_common_plaintext_files_in_repos , args [ :custom_pr_comment ] , args [ :force ] == "force" )
491
+ force_update ( update_common_plaintext_files_in_repos , args [ :custom_pr_comment ] , should_force? ( args ) )
492
492
end
493
493
end
494
494
@@ -598,6 +598,14 @@ def force_update(branch, custom_pr_comment, skip_confirmation=false, opts={})
598
598
end
599
599
end
600
600
601
+ def should_force? ( opts = { } )
602
+ force = opts [ :force ]
603
+ %w[ force t true ] . each do |text |
604
+ return true if force == text || ENV [ 'FORCE' ] == text
605
+ end
606
+ return false
607
+ end
608
+
601
609
def update_files_in_repos ( purpose , suffix = '' , opts = { } )
602
610
suffix = [ BASE_BRANCH , ENV [ 'BRANCH_SUFFIX' ] ] . compact . join ( '-' )
603
611
branch_name = "update-#{ purpose . gsub ' ' , '-' } -#{ ENV . fetch ( 'BRANCH_DATE' , Date . today . iso8601 ) } -for-#{ suffix } "
0 commit comments