Skip to content

Commit 8064c57

Browse files
committed
Parse more types for force
1 parent 3f40099 commit 8064c57

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Rakefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ namespace :git do
224224
desc 'git push on all the repos'
225225
task :push, :force do |t, args|
226226
branch = `git rev-parse --abbrev-ref HEAD`
227-
if args[:force]
227+
if should_force?(args)
228228
run_command "git push origin #{branch} --force-with-lease"
229229
else
230230
run_command "git push origin #{branch}"
@@ -396,8 +396,8 @@ namespace :ci do
396396

397397
desc "Updates the CI files and creates a PR"
398398
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)
401401
end
402402
end
403403

@@ -488,7 +488,7 @@ namespace :common_plaintext_files do
488488

489489
desc "Updates the common plaintext files files and creates a PR"
490490
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))
492492
end
493493
end
494494

@@ -598,6 +598,14 @@ def force_update(branch, custom_pr_comment, skip_confirmation=false, opts={})
598598
end
599599
end
600600

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+
601609
def update_files_in_repos(purpose, suffix='', opts={})
602610
suffix = [BASE_BRANCH, ENV['BRANCH_SUFFIX']].compact.join('-')
603611
branch_name = "update-#{purpose.gsub ' ', '-'}-#{ENV.fetch('BRANCH_DATE',Date.today.iso8601)}-for-#{suffix}"

0 commit comments

Comments
 (0)