Skip to content

Commit 6202b76

Browse files
authored
Merge pull request #240 from rspec/add-context-when-generating-pr
Be able to refer to pull request from rspec-dev in each rspec gems PR
2 parents 8050208 + 3b1878c commit 6202b76

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Rakefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,16 @@ BASE_BRANCH_MAJOR_VERSION = if BASE_BRANCH == 'master'
222222
Integer(BASE_BRANCH[/^\d+/])
223223
end
224224

225-
def create_pull_request(project_name, branch, base=BASE_BRANCH)
225+
def create_pull_request(project_name, branch, custom_pr_comment, base=BASE_BRANCH)
226+
body = [
227+
"These are some updates, generated from rspec-dev's rake tasks.",
228+
custom_pr_comment
229+
].join("\n\n").strip
230+
226231
github_client.create_pull_request(
227232
"rspec/#{project_name}", base, branch,
228233
"Updates from rspec-dev (#{Date.today.iso8601})",
229-
"These are some updates, generated from rspec-dev's rake tasks."
234+
body
230235
)
231236
end
232237

@@ -296,8 +301,8 @@ namespace :travis do
296301
end
297302

298303
desc "Updates the travis files and creates a PR"
299-
task :create_pr_with_updates do
300-
force_update update_travis_files_in_repos
304+
task :create_pr_with_updates, :custom_pr_comment do |t, args|
305+
force_update(update_travis_files_in_repos, args[:custom_pr_comment])
301306
end
302307
end
303308

@@ -374,8 +379,8 @@ namespace :common_plaintext_files do
374379
end
375380

376381
desc "Updates the common plaintext files files and creates a PR"
377-
task :create_pr_with_updates do
378-
force_update update_common_plaintext_files_in_repos
382+
task :create_pr_with_updates, :custom_pr_comment do |_t, args|
383+
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment])
379384
end
380385
end
381386

@@ -465,16 +470,16 @@ def each_project_with_common_build(&b)
465470
each_project(:except => except, &b)
466471
end
467472

468-
def force_update(branch)
473+
def force_update(branch, custom_pr_comment)
469474
each_project_with_common_build do |name|
470475
unless system("git push origin #{branch}")
471476
puts "Push failed, force? (y/n)"
472477
if STDIN.gets.downcase =~ /^y/
473478
sh "git push origin +#{branch}"
474479
end
475-
create_pull_request(name, branch) rescue nil
480+
create_pull_request(name, branch, custom_pr_comment) rescue nil
476481
else
477-
create_pull_request(name, branch)
482+
create_pull_request(name, branch, custom_pr_comment)
478483
end
479484
sh "git checkout #{BASE_BRANCH} && git branch -D #{branch}" # no need to keep it around
480485
end

0 commit comments

Comments
 (0)