summaryrefslogtreecommitdiff
path: root/tool/sync_test_lib.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-24 13:31:32 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-24 13:31:32 +0900
commitdf21e7ebabc661a789be5c2f49cfb4e4b67913b7 (patch)
treeb8c25f4a2be1dabd1e8b373ea05d43c17ab98ead /tool/sync_test_lib.rb
parentb4e438d8aabaf4bba2b27f374c787543fae07c58 (diff)
downloadruby-df21e7ebabc661a789be5c2f49cfb4e4b67913b7.tar.gz
Added sync tools for test libraries like core_assertions.rb to default gems repositories
Diffstat (limited to 'tool/sync_test_lib.rb')
-rwxr-xr-xtool/sync_test_lib.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/tool/sync_test_lib.rb b/tool/sync_test_lib.rb
new file mode 100755
index 0000000000..d950b4994d
--- /dev/null
+++ b/tool/sync_test_lib.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+
+require "fileutils"
+
+test_lib_files = %w[core_assertions.rb find_executable.rb envutil.rb]
+
+repos = %w[
+ bigdecimal cgi cmath date delegate did_you_mean digest drb erb etc
+ fileutils find forwardable io-console io-nonblock io-wait ipaddr
+ irb logger net-http net-protocol open-uri open3 openssl optparse
+ ostruct pathname pstore psych racc resolv stringio strscan tempfile
+ time timeout tmpdir uri weakref win32ole yaml zlib
+]
+
+branch_name = "update-test-lib-#{Time.now.strftime("%Y%m%d")}"
+title = "Update test libraries from ruby/ruby #{Time.now.strftime("%Y-%m-%d")}"
+commit = `git rev-parse HEAD`.chomp
+message = "Update test libraries from https://github.com/ruby/ruby/commit/#{commit}"
+
+repos.each do |repo|
+ puts "#{repo}: start"
+
+ Dir.chdir("../#{repo}") do
+ if `git branch --list #{branch_name}`.empty?
+ system "git switch master"
+ system "git switch -c #{branch_name}"
+ else
+ puts "#{repo}: "
+ next
+ end
+
+ test_lib_files.each do |file|
+ FileUtils.cp("../ruby/tool/lib/#{file}", "test/lib/#{file}")
+ system "git add test/lib/#{file}"
+ end
+
+ if `git commit -m '#{message}'`.chomp =~ /nothing to commit/
+ puts "#{repo}: nothing to update"
+ else
+ system "git push"
+ system "gh repo set-default ruby/#{repo}"
+ system "gh pr create --base master --head ruby:#{branch_name} --title \"#{title}\" --body \"#{message}\""
+ puts "#{repo}: updated"
+ end
+
+ system "git switch master"
+ system "git branch -D #{branch_name}"
+ end
+rescue StandardError => e
+ ptus e
+end