2020-07-12 11:31:12 -04:00
|
|
|
# sync upstream github repositories to ruby repository
|
2017-06-28 06:18:03 -04:00
|
|
|
|
2019-07-14 01:29:38 -04:00
|
|
|
require 'fileutils'
|
2019-07-14 02:22:12 -04:00
|
|
|
include FileUtils
|
2019-07-14 01:29:38 -04:00
|
|
|
|
2020-08-29 05:51:05 -04:00
|
|
|
REPOSITORIES = {
|
2017-06-28 06:18:03 -04:00
|
|
|
rubygems: 'rubygems/rubygems',
|
2020-03-16 06:28:52 -04:00
|
|
|
bundler: 'rubygems/rubygems',
|
2017-08-29 07:52:50 -04:00
|
|
|
rdoc: 'ruby/rdoc',
|
2019-04-27 01:53:09 -04:00
|
|
|
reline: 'ruby/reline',
|
2017-06-28 06:18:03 -04:00
|
|
|
json: 'flori/json',
|
2017-07-14 01:33:15 -04:00
|
|
|
psych: 'ruby/psych',
|
2017-06-28 06:18:03 -04:00
|
|
|
fileutils: 'ruby/fileutils',
|
|
|
|
fiddle: 'ruby/fiddle',
|
|
|
|
stringio: 'ruby/stringio',
|
2020-01-21 23:44:41 -05:00
|
|
|
"io-console": 'ruby/io-console',
|
2020-07-30 08:21:08 -04:00
|
|
|
"io-nonblock": 'ruby/io-nonblock',
|
2020-07-30 08:10:28 -04:00
|
|
|
"io-wait": 'ruby/io-wait',
|
2017-06-28 06:18:03 -04:00
|
|
|
csv: 'ruby/csv',
|
|
|
|
dbm: 'ruby/dbm',
|
|
|
|
gdbm: 'ruby/gdbm',
|
|
|
|
etc: 'ruby/etc',
|
|
|
|
date: 'ruby/date',
|
|
|
|
zlib: 'ruby/zlib',
|
|
|
|
fcntl: 'ruby/fcntl',
|
|
|
|
strscan: 'ruby/strscan',
|
2017-08-01 22:20:48 -04:00
|
|
|
ipaddr: 'ruby/ipaddr',
|
2018-06-11 03:42:28 -04:00
|
|
|
logger: 'ruby/logger',
|
|
|
|
prime: 'ruby/prime',
|
|
|
|
matrix: 'ruby/matrix',
|
|
|
|
ostruct: 'ruby/ostruct',
|
2018-07-09 10:01:05 -04:00
|
|
|
irb: 'ruby/irb',
|
2018-07-19 22:24:59 -04:00
|
|
|
tracer: 'ruby/tracer',
|
2018-07-25 08:15:45 -04:00
|
|
|
forwardable: "ruby/forwardable",
|
2019-05-14 08:36:59 -04:00
|
|
|
mutex_m: "ruby/mutex_m",
|
2019-11-05 21:29:51 -05:00
|
|
|
racc: "ruby/racc",
|
2019-11-06 08:17:03 -05:00
|
|
|
singleton: "ruby/singleton",
|
|
|
|
open3: "ruby/open3",
|
2019-11-06 18:43:10 -05:00
|
|
|
getoptlong: "ruby/getoptlong",
|
2019-11-06 21:17:12 -05:00
|
|
|
pstore: "ruby/pstore",
|
2019-11-06 23:21:46 -05:00
|
|
|
delegate: "ruby/delegate",
|
2019-11-06 23:53:05 -05:00
|
|
|
benchmark: "ruby/benchmark",
|
2020-01-21 23:44:41 -05:00
|
|
|
"net-pop": "ruby/net-pop",
|
|
|
|
"net-smtp": "ruby/net-smtp",
|
2019-11-07 02:34:03 -05:00
|
|
|
cgi: "ruby/cgi",
|
2019-11-08 00:31:43 -05:00
|
|
|
readline: "ruby/readline",
|
2020-01-21 23:44:41 -05:00
|
|
|
"readline-ext": "ruby/readline-ext",
|
2019-11-08 01:47:18 -05:00
|
|
|
observer: "ruby/observer",
|
2019-11-08 05:21:47 -05:00
|
|
|
timeout: "ruby/timeout",
|
2019-11-08 06:18:08 -05:00
|
|
|
yaml: "ruby/yaml",
|
2019-11-11 08:17:50 -05:00
|
|
|
uri: "ruby/uri",
|
2019-11-26 04:25:56 -05:00
|
|
|
openssl: "ruby/openssl",
|
2020-02-11 00:05:04 -05:00
|
|
|
did_you_mean: "ruby/did_you_mean",
|
|
|
|
weakref: "ruby/weakref",
|
2020-02-12 05:39:20 -05:00
|
|
|
tempfile: "ruby/tempfile",
|
2020-02-12 06:07:15 -05:00
|
|
|
tmpdir: "ruby/tmpdir",
|
2020-02-13 06:35:34 -05:00
|
|
|
English: "ruby/English",
|
2020-02-17 08:15:20 -05:00
|
|
|
"net-protocol": "ruby/net-protocol",
|
2020-02-20 07:22:56 -05:00
|
|
|
"net-imap": "ruby/net-imap",
|
2020-02-21 05:09:21 -05:00
|
|
|
"net-ftp": "ruby/net-ftp",
|
2020-02-21 07:21:14 -05:00
|
|
|
"net-http": "ruby/net-http",
|
2020-07-05 09:08:04 -04:00
|
|
|
bigdecimal: "ruby/bigdecimal",
|
2020-07-22 05:38:51 -04:00
|
|
|
optparse: "ruby/optparse",
|
2020-08-19 23:39:11 -04:00
|
|
|
set: "ruby/set",
|
2020-08-20 08:00:48 -04:00
|
|
|
find: "ruby/find",
|
2020-08-21 05:10:03 -04:00
|
|
|
rinda: "ruby/rinda",
|
2020-08-21 07:18:44 -04:00
|
|
|
erb: "ruby/erb",
|
2020-08-25 08:17:19 -04:00
|
|
|
nkf: "ruby/nkf",
|
2020-09-09 08:53:09 -04:00
|
|
|
tsort: "ruby/tsort",
|
2020-09-10 00:54:28 -04:00
|
|
|
abbrev: "ruby/abbrev",
|
2020-09-10 02:42:23 -04:00
|
|
|
shellwords: "ruby/shellwords",
|
2020-09-10 05:56:13 -04:00
|
|
|
base64: "ruby/base64",
|
2020-09-10 07:42:53 -04:00
|
|
|
syslog: "ruby/syslog",
|
2020-09-11 07:38:18 -04:00
|
|
|
"open-uri": "ruby/open-uri",
|
2020-09-11 08:15:25 -04:00
|
|
|
securerandom: "ruby/securerandom",
|
2020-09-11 08:50:07 -04:00
|
|
|
resolv: "ruby/resolv",
|
2020-09-11 09:01:08 -04:00
|
|
|
"resolv-replace": "ruby/resolv-replace",
|
2020-09-11 19:29:06 -04:00
|
|
|
time: "ruby/time",
|
2020-10-06 07:45:06 -04:00
|
|
|
pp: "ruby/pp",
|
2020-10-06 08:05:03 -04:00
|
|
|
prettyprint: "ruby/prettyprint",
|
2020-10-13 08:06:13 -04:00
|
|
|
drb: "ruby/drb",
|
2020-10-13 09:28:59 -04:00
|
|
|
pathname: "ruby/pathname",
|
2020-10-19 05:56:19 -04:00
|
|
|
digest: "ruby/digest",
|
2017-06-28 06:18:03 -04:00
|
|
|
}
|
|
|
|
|
2017-07-02 22:13:59 -04:00
|
|
|
def sync_default_gems(gem)
|
2021-01-05 07:23:07 -05:00
|
|
|
repo = REPOSITORIES[gem.to_sym]
|
|
|
|
puts "Sync #{repo}"
|
2017-07-02 22:13:59 -04:00
|
|
|
|
2021-01-05 07:23:07 -05:00
|
|
|
upstream = File.join("..", "..", repo)
|
2019-07-14 01:17:06 -04:00
|
|
|
|
2017-07-02 22:13:59 -04:00
|
|
|
case gem
|
|
|
|
when "rubygems"
|
2020-05-22 18:27:42 -04:00
|
|
|
rm_rf(%w[lib/rubygems lib/rubygems.rb test/rubygems])
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/rubygems*"), "lib")
|
|
|
|
cp_r("#{upstream}/test/rubygems", "test")
|
2018-11-02 19:07:56 -04:00
|
|
|
when "bundler"
|
2020-09-01 07:46:53 -04:00
|
|
|
rm_rf(%w[lib/bundler lib/bundler.rb libexec/bundler libexec/bundle spec/bundler] + Dir.glob("man/{bundle*,gemfile*}"))
|
2020-03-16 06:28:52 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/bundler/lib/bundler*"), "lib")
|
|
|
|
cp_r(Dir.glob("#{upstream}/bundler/exe/bundle*"), "libexec")
|
|
|
|
cp_r("#{upstream}/bundler/bundler.gemspec", "lib/bundler")
|
|
|
|
cp_r("#{upstream}/bundler/spec", "spec/bundler")
|
|
|
|
cp_r(Dir.glob("#{upstream}/bundler/man/*.{1,5,1\.txt,5\.txt,ronn}"), "man")
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes])
|
2017-07-02 22:13:59 -04:00
|
|
|
when "rdoc"
|
2020-05-22 18:27:42 -04:00
|
|
|
rm_rf(%w[lib/rdoc lib/rdoc.rb test/rdoc libexec/rdoc libexec/ri])
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib")
|
2019-07-26 03:34:15 -04:00
|
|
|
cp_r("#{upstream}/test/rdoc", "test")
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc")
|
|
|
|
cp_r("#{upstream}/exe/rdoc", "libexec")
|
|
|
|
cp_r("#{upstream}/exe/ri", "libexec")
|
2021-03-12 22:14:18 -05:00
|
|
|
parser_files = {
|
|
|
|
'lib/rdoc/markdown.kpeg' => 'lib/rdoc/markdown.rb',
|
|
|
|
'lib/rdoc/markdown/literals.kpeg' => 'lib/rdoc/markdown/literals.rb',
|
|
|
|
'lib/rdoc/rd/block_parser.ry' => 'lib/rdoc/rd/block_parser.rb',
|
|
|
|
'lib/rdoc/rd/inline_parser.ry' => 'lib/rdoc/rd/inline_parser.rb'
|
|
|
|
}
|
|
|
|
Dir.chdir(upstream) do
|
|
|
|
parser_files.each_value do |dst|
|
|
|
|
`bundle exec rake #{dst}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
parser_files.each_pair do |src, dst|
|
|
|
|
rm_rf(src)
|
|
|
|
cp_r("#{upstream}/#{dst}", dst)
|
|
|
|
end
|
2017-08-29 07:52:50 -04:00
|
|
|
`git checkout lib/rdoc/.document`
|
2019-04-27 01:53:09 -04:00
|
|
|
when "reline"
|
2020-05-22 18:27:42 -04:00
|
|
|
rm_rf(%w[lib/reline lib/reline.rb test/reline])
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/reline*"), "lib")
|
2019-08-17 18:52:49 -04:00
|
|
|
cp_r("#{upstream}/test/reline", "test")
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r("#{upstream}/reline.gemspec", "lib/reline")
|
2017-07-02 22:13:59 -04:00
|
|
|
when "json"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/json test/json])
|
|
|
|
cp_r("#{upstream}/ext/json/ext", "ext/json")
|
|
|
|
cp_r("#{upstream}/tests", "test/json")
|
2020-12-22 04:18:32 -05:00
|
|
|
rm_rf("test/json/lib")
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r("#{upstream}/lib", "ext/json")
|
|
|
|
cp_r("#{upstream}/json.gemspec", "ext/json")
|
2020-12-17 00:20:42 -05:00
|
|
|
cp_r("#{upstream}/VERSION", "ext/json")
|
2019-10-30 21:18:57 -04:00
|
|
|
rm_rf(%w[ext/json/lib/json/ext ext/json/lib/json/pure.rb ext/json/lib/json/pure])
|
|
|
|
`git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend ext/json/depend`
|
2017-07-02 22:13:59 -04:00
|
|
|
when "psych"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/psych test/psych])
|
|
|
|
cp_r("#{upstream}/ext/psych", "ext")
|
|
|
|
cp_r("#{upstream}/lib", "ext/psych")
|
|
|
|
cp_r("#{upstream}/test/psych", "test")
|
|
|
|
rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb])
|
|
|
|
rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*])
|
|
|
|
rm_rf(["ext/psych/yaml/LICENSE"])
|
|
|
|
cp_r("#{upstream}/psych.gemspec", "ext/psych")
|
2017-07-14 01:33:15 -04:00
|
|
|
`git checkout ext/psych/depend`
|
2017-07-02 22:13:59 -04:00
|
|
|
when "fiddle"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/fiddle test/fiddle])
|
|
|
|
cp_r("#{upstream}/ext/fiddle", "ext")
|
|
|
|
cp_r("#{upstream}/lib", "ext/fiddle")
|
|
|
|
cp_r("#{upstream}/test/fiddle", "test")
|
|
|
|
cp_r("#{upstream}/fiddle.gemspec", "ext/fiddle")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/fiddle/depend`
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}])
|
2017-07-02 22:13:59 -04:00
|
|
|
when "stringio"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/stringio test/stringio])
|
|
|
|
cp_r("#{upstream}/ext/stringio", "ext")
|
|
|
|
cp_r("#{upstream}/test/stringio", "test")
|
|
|
|
cp_r("#{upstream}/stringio.gemspec", "ext/stringio")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/stringio/depend ext/stringio/README.md`
|
2020-01-21 23:44:41 -05:00
|
|
|
when "io-console"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/io/console test/io/console])
|
|
|
|
cp_r("#{upstream}/ext/io/console", "ext/io")
|
|
|
|
cp_r("#{upstream}/test/io/console", "test/io")
|
|
|
|
mkdir_p("ext/io/console/lib")
|
|
|
|
cp_r("#{upstream}/lib/io/console", "ext/io/console/lib")
|
|
|
|
cp_r("#{upstream}/io-console.gemspec", "ext/io/console")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/io/console/depend`
|
2020-07-30 08:21:08 -04:00
|
|
|
when "io-nonblock"
|
|
|
|
rm_rf(%w[ext/io/nonblock test/io/nonblock])
|
|
|
|
cp_r("#{upstream}/ext/io/nonblock", "ext/io")
|
|
|
|
cp_r("#{upstream}/test/io/nonblock", "test/io")
|
|
|
|
cp_r("#{upstream}/io-nonblock.gemspec", "ext/io/nonblock")
|
|
|
|
`git checkout ext/io/nonblock/depend`
|
2020-07-30 08:10:28 -04:00
|
|
|
when "io-wait"
|
|
|
|
rm_rf(%w[ext/io/wait test/io/wait])
|
|
|
|
cp_r("#{upstream}/ext/io/wait", "ext/io")
|
|
|
|
cp_r("#{upstream}/test/io/wait", "test/io")
|
|
|
|
cp_r("#{upstream}/io-wait.gemspec", "ext/io/wait")
|
|
|
|
`git checkout ext/io/wait/depend`
|
2017-07-02 22:13:59 -04:00
|
|
|
when "dbm"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/dbm test/dbm])
|
|
|
|
cp_r("#{upstream}/ext/dbm", "ext")
|
|
|
|
cp_r("#{upstream}/test/dbm", "test")
|
|
|
|
cp_r("#{upstream}/dbm.gemspec", "ext/dbm")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/dbm/depend`
|
|
|
|
when "gdbm"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/gdbm test/gdbm])
|
|
|
|
cp_r("#{upstream}/ext/gdbm", "ext")
|
|
|
|
cp_r("#{upstream}/test/gdbm", "test")
|
|
|
|
cp_r("#{upstream}/gdbm.gemspec", "ext/gdbm")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/gdbm/depend ext/gdbm/README`
|
|
|
|
when "etc"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/etc test/etc])
|
|
|
|
cp_r("#{upstream}/ext/etc", "ext")
|
|
|
|
cp_r("#{upstream}/test/etc", "test")
|
|
|
|
cp_r("#{upstream}/etc.gemspec", "ext/etc")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/etc/depend`
|
|
|
|
when "date"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/date test/date])
|
|
|
|
cp_r("#{upstream}/ext/date", "ext")
|
|
|
|
cp_r("#{upstream}/lib", "ext/date")
|
|
|
|
cp_r("#{upstream}/test/date", "test")
|
|
|
|
cp_r("#{upstream}/date.gemspec", "ext/date")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/date/depend`
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(["ext/date/lib/date_core.bundle"])
|
2017-07-02 22:13:59 -04:00
|
|
|
when "zlib"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/zlib test/zlib])
|
|
|
|
cp_r("#{upstream}/ext/zlib", "ext")
|
|
|
|
cp_r("#{upstream}/test/zlib", "test")
|
|
|
|
cp_r("#{upstream}/zlib.gemspec", "ext/zlib")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/zlib/depend`
|
|
|
|
when "fcntl"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/fcntl])
|
|
|
|
cp_r("#{upstream}/ext/fcntl", "ext")
|
|
|
|
cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl")
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/fcntl/depend`
|
|
|
|
when "strscan"
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(%w[ext/strscan test/strscan])
|
|
|
|
cp_r("#{upstream}/ext/strscan", "ext")
|
|
|
|
cp_r("#{upstream}/test/strscan", "test")
|
|
|
|
cp_r("#{upstream}/strscan.gemspec", "ext/strscan")
|
|
|
|
rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"])
|
2017-07-02 22:13:59 -04:00
|
|
|
`git checkout ext/strscan/depend`
|
2019-05-14 08:36:59 -04:00
|
|
|
when "racc"
|
2020-05-22 18:27:42 -04:00
|
|
|
rm_rf(%w[lib/racc lib/racc.rb ext/racc test/racc])
|
2019-07-14 02:22:12 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib")
|
|
|
|
mkdir_p("ext/racc/cparse")
|
|
|
|
cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse")
|
|
|
|
cp_r("#{upstream}/test", "test/racc")
|
2019-12-10 03:03:13 -05:00
|
|
|
cp_r("#{upstream}/racc.gemspec", "lib/racc")
|
2019-10-30 08:00:01 -04:00
|
|
|
rm_rf("test/racc/lib")
|
|
|
|
rm_rf("lib/racc/cparse-jruby.jar")
|
|
|
|
`git checkout ext/racc/cparse/README ext/racc/cparse/depend`
|
2019-11-07 02:34:03 -05:00
|
|
|
when "cgi"
|
|
|
|
rm_rf(%w[lib/cgi.rb lib/cgi ext/cgi test/cgi])
|
|
|
|
cp_r("#{upstream}/ext/cgi", "ext")
|
|
|
|
cp_r("#{upstream}/lib", ".")
|
|
|
|
cp_r("#{upstream}/test/cgi", "test")
|
|
|
|
cp_r("#{upstream}/cgi.gemspec", "lib/cgi")
|
|
|
|
`git checkout ext/cgi/escape/depend`
|
2019-11-26 04:25:56 -05:00
|
|
|
when "openssl"
|
|
|
|
rm_rf(%w[ext/openssl test/openssl])
|
|
|
|
cp_r("#{upstream}/ext/openssl", "ext")
|
2020-03-10 04:24:47 -04:00
|
|
|
cp_r("#{upstream}/lib", "ext/openssl")
|
|
|
|
cp_r("#{upstream}/test/openssl", "test")
|
2019-11-26 04:25:56 -05:00
|
|
|
rm_rf("test/openssl/envutil.rb")
|
|
|
|
cp_r("#{upstream}/openssl.gemspec", "ext/openssl")
|
2020-03-10 04:24:47 -04:00
|
|
|
cp_r("#{upstream}/History.md", "ext/openssl")
|
2019-11-26 04:25:56 -05:00
|
|
|
`git checkout ext/openssl/depend`
|
2020-01-21 23:44:41 -05:00
|
|
|
when "net-pop"
|
2020-08-05 07:01:03 -04:00
|
|
|
rm_rf(%w[lib/net/pop.rb lib/net/net-pop.gemspec test/net/pop])
|
2020-02-21 07:30:04 -05:00
|
|
|
cp_r("#{upstream}/lib/net/pop.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/pop", "test/net")
|
2020-08-05 07:01:03 -04:00
|
|
|
cp_r("#{upstream}/net-pop.gemspec", "lib/net")
|
2020-01-21 23:44:41 -05:00
|
|
|
when "net-smtp"
|
2020-08-05 07:01:03 -04:00
|
|
|
rm_rf(%w[lib/net/smtp.rb lib/net/net-smtp.gemspec test/net/smtp])
|
2020-02-21 07:30:04 -05:00
|
|
|
cp_r("#{upstream}/lib/net/smtp.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/smtp", "test/net")
|
2020-08-05 07:01:03 -04:00
|
|
|
cp_r("#{upstream}/net-smtp.gemspec", "lib/net")
|
2020-02-17 08:15:20 -05:00
|
|
|
when "net-protocol"
|
2020-08-05 07:01:03 -04:00
|
|
|
rm_rf(%w[lib/net/protocol.rb lib/net/net-protocol.gemspec test/net/protocol])
|
2020-02-21 07:30:04 -05:00
|
|
|
cp_r("#{upstream}/lib/net/protocol.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/protocol", "test/net")
|
2020-08-05 07:01:03 -04:00
|
|
|
cp_r("#{upstream}/net-protocol.gemspec", "lib/net")
|
2020-02-20 07:22:56 -05:00
|
|
|
when "net-imap"
|
2020-08-05 07:01:03 -04:00
|
|
|
rm_rf(%w[lib/net/imap.rb lib/net/net-imap.gemspec test/net/imap])
|
2020-02-21 07:30:04 -05:00
|
|
|
cp_r("#{upstream}/lib/net/imap.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/imap", "test/net")
|
2020-08-05 07:01:03 -04:00
|
|
|
cp_r("#{upstream}/net-imap.gemspec", "lib/net")
|
2020-02-21 05:09:21 -05:00
|
|
|
when "net-ftp"
|
2020-08-03 04:40:05 -04:00
|
|
|
rm_rf(%w[lib/net/ftp.rb lib/net/net-ftp.gemspec test/net/ftp])
|
2020-02-21 07:25:43 -05:00
|
|
|
cp_r("#{upstream}/lib/net/ftp.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/ftp", "test/net")
|
2020-08-03 04:40:05 -04:00
|
|
|
cp_r("#{upstream}/net-ftp.gemspec", "lib/net")
|
2020-02-21 07:21:14 -05:00
|
|
|
when "net-http"
|
|
|
|
rm_rf(%w[lib/net/http.rb lib/net/http test/net/http])
|
|
|
|
cp_r("#{upstream}/lib/net/http.rb", "lib/net")
|
|
|
|
cp_r("#{upstream}/lib/net/http", "lib/net")
|
|
|
|
cp_r("#{upstream}/test/net/http", "test/net")
|
|
|
|
cp_r("#{upstream}/net-http.gemspec", "lib/net/http")
|
2020-01-21 23:44:41 -05:00
|
|
|
when "readline-ext"
|
2020-02-06 07:19:44 -05:00
|
|
|
rm_rf(%w[ext/readline test/readline])
|
|
|
|
cp_r("#{upstream}/ext/readline", "ext")
|
|
|
|
cp_r("#{upstream}/test/readline", "test")
|
|
|
|
cp_r("#{upstream}/readline-ext.gemspec", "ext/readline")
|
2020-02-10 05:41:07 -05:00
|
|
|
`git checkout ext/readline/depend`
|
2019-10-29 10:08:37 -04:00
|
|
|
when "did_you_mean"
|
2020-05-22 18:27:42 -04:00
|
|
|
rm_rf(%w[lib/did_you_mean lib/did_you_mean.rb test/did_you_mean])
|
2019-10-29 10:08:37 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/did_you_mean*"), "lib")
|
|
|
|
cp_r("#{upstream}/did_you_mean.gemspec", "lib/did_you_mean")
|
|
|
|
cp_r("#{upstream}/test", "test/did_you_mean")
|
|
|
|
rm_rf(%w[test/did_you_mean/tree_spell/test_explore.rb])
|
2020-08-21 07:18:44 -04:00
|
|
|
when "erb"
|
|
|
|
rm_rf(%w[lib/erb* test/erb libexec/erb])
|
|
|
|
cp_r("#{upstream}/lib/erb.rb", "lib")
|
|
|
|
cp_r("#{upstream}/test/erb", "test")
|
|
|
|
cp_r("#{upstream}/erb.gemspec", "lib")
|
2020-09-18 05:44:46 -04:00
|
|
|
cp_r("#{upstream}/libexec/erb", "libexec")
|
2020-08-25 08:17:19 -04:00
|
|
|
when "nkf"
|
|
|
|
rm_rf(%w[ext/nkf test/nkf])
|
|
|
|
cp_r("#{upstream}/ext/nkf", "ext")
|
|
|
|
cp_r("#{upstream}/lib", "ext/nkf")
|
|
|
|
cp_r("#{upstream}/test/nkf", "test")
|
|
|
|
cp_r("#{upstream}/nkf.gemspec", "ext/nkf")
|
|
|
|
`git checkout ext/nkf/depend`
|
2020-09-10 07:42:53 -04:00
|
|
|
when "syslog"
|
|
|
|
rm_rf(%w[ext/syslog test/syslog test/test_syslog.rb])
|
|
|
|
cp_r("#{upstream}/ext/syslog", "ext")
|
|
|
|
cp_r("#{upstream}/lib", "ext/syslog")
|
|
|
|
cp_r("#{upstream}/test/syslog", "test")
|
|
|
|
cp_r("#{upstream}/test/test_syslog.rb", "test")
|
|
|
|
cp_r("#{upstream}/syslog.gemspec", "ext/syslog")
|
|
|
|
`git checkout ext/syslog/depend`
|
2020-09-18 05:47:52 -04:00
|
|
|
when "bigdecimal"
|
|
|
|
rm_rf(%w[ext/bigdecimal test/bigdecimal])
|
|
|
|
cp_r("#{upstream}/ext/bigdecimal", "ext")
|
|
|
|
cp_r("#{upstream}/sample", "ext/bigdecimal")
|
|
|
|
cp_r("#{upstream}/lib", "ext/bigdecimal")
|
|
|
|
cp_r("#{upstream}/test/bigdecimal", "test")
|
|
|
|
cp_r("#{upstream}/bigdecimal.gemspec", "ext/bigdecimal")
|
|
|
|
`git checkout ext/bigdecimal/depend`
|
2020-10-13 09:28:59 -04:00
|
|
|
when "pathname"
|
|
|
|
rm_rf(%w[ext/pathname test/pathname])
|
|
|
|
cp_r("#{upstream}/ext/pathname", "ext")
|
|
|
|
cp_r("#{upstream}/test/pathname", "test")
|
2020-12-17 03:24:51 -05:00
|
|
|
cp_r("#{upstream}/lib", "ext/pathname")
|
2020-10-13 09:28:59 -04:00
|
|
|
cp_r("#{upstream}/pathname.gemspec", "ext/pathname")
|
|
|
|
`git checkout ext/pathname/depend`
|
2020-10-19 05:56:19 -04:00
|
|
|
when "digest"
|
|
|
|
rm_rf(%w[ext/digest test/digest])
|
|
|
|
cp_r("#{upstream}/ext/digest", "ext")
|
|
|
|
mkdir_p("#{upstream}/ext/digest/lib")
|
2020-12-14 05:39:32 -05:00
|
|
|
cp_r("#{upstream}/lib/digest.rb", "ext/digest/lib/")
|
2020-10-19 05:56:19 -04:00
|
|
|
cp_r("#{upstream}/test/digest", "test")
|
|
|
|
cp_r("#{upstream}/digest.gemspec", "ext/digest")
|
|
|
|
`git checkout ext/digest/depend ext/digest/*/depend`
|
2020-12-21 22:17:47 -05:00
|
|
|
when "set"
|
|
|
|
sync_lib gem, upstream
|
|
|
|
cp_r("#{upstream}/test", ".")
|
2017-07-02 22:13:59 -04:00
|
|
|
else
|
2020-10-04 09:55:27 -04:00
|
|
|
sync_lib gem, upstream
|
2017-07-02 22:13:59 -04:00
|
|
|
end
|
2017-06-28 06:18:03 -04:00
|
|
|
end
|
|
|
|
|
2020-07-12 10:59:18 -04:00
|
|
|
IGNORE_FILE_PATTERN =
|
|
|
|
/\A(?:[A-Z]\w*\.(?:md|txt)
|
|
|
|
|[^\/]+\.yml
|
|
|
|
|\.git.*
|
|
|
|
|[A-Z]\w+file
|
|
|
|
)\z/x
|
2019-07-26 22:23:47 -04:00
|
|
|
|
2021-03-28 00:57:48 -04:00
|
|
|
def message_filter(repo, sha)
|
|
|
|
log = STDIN.read
|
|
|
|
print "[#{repo}] ", log.sub(/\s*(?=(?i:\nCo-authored-by:.*)*\Z)/) {
|
|
|
|
"\n\n" "https://github.com/#{repo}/commit/#{sha[0,10]}\n"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-07-12 10:40:27 -04:00
|
|
|
def sync_default_gems_with_commits(gem, ranges, edit: nil)
|
2021-01-05 07:23:07 -05:00
|
|
|
repo = REPOSITORIES[gem.to_sym]
|
|
|
|
puts "Sync #{repo} with commit history."
|
2019-07-14 03:56:39 -04:00
|
|
|
|
|
|
|
IO.popen(%W"git remote") do |f|
|
|
|
|
unless f.read.split.include?(gem)
|
2021-01-05 07:23:07 -05:00
|
|
|
`git remote add #{gem} git@github.com:#{repo}.git`
|
2019-07-14 03:56:39 -04:00
|
|
|
end
|
|
|
|
end
|
2019-11-03 19:38:34 -05:00
|
|
|
system(*%W"git fetch --no-tags #{gem}")
|
2019-07-14 04:15:06 -04:00
|
|
|
|
2021-01-05 07:24:10 -05:00
|
|
|
if ranges == true
|
|
|
|
log = IO.popen(%W"git log --fixed-strings --grep=[#{repo}] -n1 --format=%B", &:read)
|
2021-03-28 00:57:48 -04:00
|
|
|
ranges = ["#{log[%r[https://github\.com/#{Regexp.quote(repo)}/commit/(\h+)\n\s*(?i:co-authored-by:.*)*\s*\Z], 1]}..#{gem}/master"]
|
2021-01-05 07:24:10 -05:00
|
|
|
end
|
|
|
|
|
2020-07-05 11:33:03 -04:00
|
|
|
commits = ranges.flat_map do |range|
|
|
|
|
unless range.include?("..")
|
|
|
|
range = "#{range}~1..#{range}"
|
|
|
|
end
|
2019-11-30 00:48:26 -05:00
|
|
|
|
2020-07-05 11:33:03 -04:00
|
|
|
IO.popen(%W"git log --format=%H,%s #{range}") do |f|
|
|
|
|
f.read.split("\n").reverse.map{|commit| commit.split(',', 2)}
|
|
|
|
end
|
2019-07-26 05:14:32 -04:00
|
|
|
end
|
2019-07-26 04:06:54 -04:00
|
|
|
|
2019-07-26 05:14:32 -04:00
|
|
|
# Ignore Merge commit and insufficiency commit for ruby core repository.
|
|
|
|
commits.delete_if do |sha, subject|
|
2020-04-01 05:40:27 -04:00
|
|
|
files = IO.popen(%W"git diff-tree --no-commit-id --name-only -r #{sha}", &:readlines)
|
2019-08-07 09:29:02 -04:00
|
|
|
subject =~ /^Merge/ || subject =~ /^Auto Merge/ || files.all?{|file| file =~ IGNORE_FILE_PATTERN}
|
2019-07-26 05:14:32 -04:00
|
|
|
end
|
2019-07-26 04:06:54 -04:00
|
|
|
|
2021-03-28 01:07:18 -04:00
|
|
|
if commits.empty?
|
|
|
|
puts "No commits to pick"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-07-26 05:14:32 -04:00
|
|
|
puts "Try to pick these commits:"
|
|
|
|
puts commits.map{|commit| commit.join(": ")}.join("\n")
|
|
|
|
puts "----"
|
2019-07-14 04:53:14 -04:00
|
|
|
|
2019-07-26 23:31:07 -04:00
|
|
|
failed_commits = []
|
|
|
|
|
2019-12-17 09:38:18 -05:00
|
|
|
ENV["FILTER_BRANCH_SQUELCH_WARNING"] = "1"
|
|
|
|
|
2021-03-28 00:57:48 -04:00
|
|
|
filter = [ENV.fetch('RUBY', 'ruby'), File.realpath(__FILE__), "--message-filter"]
|
2019-07-26 05:14:32 -04:00
|
|
|
commits.each do |sha, subject|
|
2021-01-05 07:23:07 -05:00
|
|
|
puts "Pick #{sha} from #{repo}."
|
2019-07-14 08:31:16 -04:00
|
|
|
|
2019-07-26 23:31:07 -04:00
|
|
|
skipped = false
|
2020-04-01 05:36:54 -04:00
|
|
|
result = IO.popen(%W"git cherry-pick #{sha}", &:read)
|
2019-07-26 23:31:07 -04:00
|
|
|
if result =~ /nothing\ to\ commit/
|
|
|
|
`git reset`
|
|
|
|
skipped = true
|
|
|
|
puts "Skip empty commit #{sha}"
|
|
|
|
end
|
|
|
|
next if skipped
|
|
|
|
|
|
|
|
if result.empty?
|
2020-04-01 05:40:27 -04:00
|
|
|
skipped = true
|
2020-04-20 08:23:26 -04:00
|
|
|
elsif /^CONFLICT/ =~ result
|
2020-04-01 05:40:27 -04:00
|
|
|
result = IO.popen(%W"git status --porcelain", &:readlines).each(&:chomp!)
|
2020-07-12 10:40:27 -04:00
|
|
|
result.map! {|line| line[/^.U (.*)/, 1]}
|
|
|
|
result.compact!
|
|
|
|
ignore, conflict = result.partition {|name| IGNORE_FILE_PATTERN =~ name}
|
2020-04-20 08:23:26 -04:00
|
|
|
unless ignore.empty?
|
|
|
|
system(*%W"git reset HEAD --", *ignore)
|
|
|
|
system(*%W"git checkout HEAD --", *ignore)
|
|
|
|
end
|
2020-07-12 10:40:27 -04:00
|
|
|
unless conflict.empty?
|
|
|
|
if edit
|
|
|
|
case
|
|
|
|
when (editor = ENV["GIT_EDITOR"] and !editor.empty?)
|
|
|
|
when (editor = `git config core.editor` and (editor.chomp!; !editor.empty?))
|
|
|
|
end
|
|
|
|
if editor
|
|
|
|
system([editor, conflict].join(' '))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-01 05:40:27 -04:00
|
|
|
skipped = !system({"GIT_EDITOR"=>"true"}, *%W"git cherry-pick --no-edit --continue")
|
|
|
|
end
|
|
|
|
|
|
|
|
if skipped
|
2019-07-26 23:31:07 -04:00
|
|
|
failed_commits << sha
|
|
|
|
`git reset` && `git checkout .` && `git clean -fd`
|
2019-07-26 05:14:32 -04:00
|
|
|
puts "Failed to pick #{sha}"
|
2020-04-01 05:40:27 -04:00
|
|
|
next
|
2019-07-26 05:14:32 -04:00
|
|
|
end
|
2019-07-26 23:31:07 -04:00
|
|
|
|
|
|
|
puts "Update commit message: #{sha}"
|
|
|
|
|
2021-03-28 00:57:48 -04:00
|
|
|
IO.popen(%W[git filter-branch -f --msg-filter #{[filter, repo, sha].join(' ')} -- HEAD~1..HEAD], &:read)
|
2019-07-26 05:14:32 -04:00
|
|
|
unless $?.success?
|
|
|
|
puts "Failed to modify commit message of #{sha}"
|
|
|
|
break
|
2019-07-14 04:15:06 -04:00
|
|
|
end
|
|
|
|
end
|
2019-07-26 23:31:07 -04:00
|
|
|
|
2019-12-07 08:02:24 -05:00
|
|
|
unless failed_commits.empty?
|
|
|
|
puts "---- failed commits ----"
|
|
|
|
puts failed_commits
|
|
|
|
end
|
2019-07-14 03:56:39 -04:00
|
|
|
end
|
|
|
|
|
2020-10-04 09:55:27 -04:00
|
|
|
def sync_lib(repo, upstream = nil)
|
|
|
|
unless upstream and File.directory?(upstream) or File.directory?(upstream = "../#{repo}")
|
|
|
|
abort %[Expected '#{upstream}' \(#{File.expand_path("#{upstream}")}\) to be a directory, but it wasn't.]
|
2019-04-26 05:18:09 -04:00
|
|
|
end
|
2019-07-14 02:22:12 -04:00
|
|
|
rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"])
|
2020-10-04 09:55:27 -04:00
|
|
|
cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
|
2018-07-25 07:53:57 -04:00
|
|
|
tests = if File.directory?("test/#{repo}")
|
|
|
|
"test/#{repo}"
|
|
|
|
else
|
|
|
|
"test/test_#{repo}.rb"
|
|
|
|
end
|
2020-10-04 09:55:27 -04:00
|
|
|
cp_r("#{upstream}/#{tests}", "test") if File.exist?("#{upstream}/#{tests}")
|
2018-07-25 07:47:04 -04:00
|
|
|
gemspec = if File.directory?("lib/#{repo}")
|
|
|
|
"lib/#{repo}/#{repo}.gemspec"
|
|
|
|
else
|
|
|
|
"lib/#{repo}.gemspec"
|
|
|
|
end
|
2020-10-04 09:55:27 -04:00
|
|
|
cp_r("#{upstream}/#{repo}.gemspec", "#{gemspec}")
|
2018-07-17 07:39:16 -04:00
|
|
|
end
|
|
|
|
|
2018-10-25 06:16:28 -04:00
|
|
|
def update_default_gems(gem)
|
2020-01-25 17:37:50 -05:00
|
|
|
|
2020-08-29 05:51:05 -04:00
|
|
|
author, repository = REPOSITORIES[gem.to_sym].split('/')
|
2018-10-25 06:16:28 -04:00
|
|
|
|
2020-01-25 17:37:50 -05:00
|
|
|
puts "Update #{author}/#{repository}"
|
|
|
|
|
2018-10-25 06:16:28 -04:00
|
|
|
unless File.exist?("../../#{author}/#{repository}")
|
2019-07-14 02:22:12 -04:00
|
|
|
mkdir_p("../../#{author}")
|
2018-10-25 06:16:28 -04:00
|
|
|
`git clone git@github.com:#{author}/#{repository}.git ../../#{author}/#{repository}`
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir("../../#{author}/#{repository}") do
|
|
|
|
unless `git remote`.match(/ruby\-core/)
|
|
|
|
`git remote add ruby-core git@github.com:ruby/ruby.git`
|
2020-04-09 05:23:49 -04:00
|
|
|
end
|
|
|
|
`git fetch ruby-core master --no-tags`
|
|
|
|
unless `git branch`.match(/ruby\-core/)
|
2020-04-24 23:15:01 -04:00
|
|
|
`git checkout ruby-core/master`
|
2018-10-25 06:16:28 -04:00
|
|
|
`git branch ruby-core`
|
|
|
|
end
|
2020-04-24 23:15:01 -04:00
|
|
|
`git checkout ruby-core`
|
2019-08-18 05:08:38 -04:00
|
|
|
`git rebase ruby-core/master`
|
2020-04-24 23:15:01 -04:00
|
|
|
`git checkout master`
|
2020-04-09 05:23:49 -04:00
|
|
|
`git fetch origin master`
|
2020-01-25 17:40:56 -05:00
|
|
|
`git rebase origin/master`
|
2018-10-25 06:16:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
case ARGV[0]
|
|
|
|
when "up"
|
2020-04-09 03:34:25 -04:00
|
|
|
if ARGV[1]
|
|
|
|
update_default_gems(ARGV[1])
|
|
|
|
else
|
2020-08-29 05:51:05 -04:00
|
|
|
REPOSITORIES.keys.each{|gem| update_default_gems(gem.to_s)}
|
2020-04-09 03:34:25 -04:00
|
|
|
end
|
2018-10-25 06:16:28 -04:00
|
|
|
when "all"
|
2020-08-29 05:51:05 -04:00
|
|
|
REPOSITORIES.keys.each{|gem| sync_default_gems(gem.to_s)}
|
2020-07-12 11:30:44 -04:00
|
|
|
when "list"
|
|
|
|
ARGV.shift
|
|
|
|
pattern = Regexp.new(ARGV.join('|'))
|
2020-08-29 05:51:05 -04:00
|
|
|
REPOSITORIES.each_pair do |name, gem|
|
2020-07-12 11:30:44 -04:00
|
|
|
next unless pattern =~ name or pattern =~ gem
|
|
|
|
printf "%-15s https://github.com/%s\n", name, gem
|
|
|
|
end
|
2021-03-28 00:57:48 -04:00
|
|
|
when "--message-filter"
|
|
|
|
ARGV.shift
|
|
|
|
abort unless ARGV.size == 2
|
|
|
|
message_filter(*ARGV)
|
|
|
|
exit
|
2020-06-14 07:10:58 -04:00
|
|
|
when nil, "-h", "--help"
|
|
|
|
puts <<-HELP
|
|
|
|
\e[1mSync with upstream code of default libraries\e[0m
|
|
|
|
|
|
|
|
\e[1mImport a default library through `git clone` and `cp -rf` (git commits are lost)\e[0m
|
|
|
|
ruby #$0 rubygems
|
|
|
|
|
|
|
|
\e[1mPick a single commit from the upstream repository\e[0m
|
|
|
|
ruby #$0 rubygems 97e9768612
|
|
|
|
|
|
|
|
\e[1mPick a commit range from the upstream repository\e[0m
|
|
|
|
ruby #$0 rubygems 97e9768612..9e53702832
|
2020-07-12 11:30:44 -04:00
|
|
|
|
|
|
|
\e[1mList known libraries\e[0m
|
|
|
|
ruby #$0 list
|
|
|
|
|
|
|
|
\e[1mList known libraries matching with patterns\e[0m
|
|
|
|
ruby #$0 list read
|
2020-06-14 07:10:58 -04:00
|
|
|
HELP
|
|
|
|
|
|
|
|
exit
|
2018-10-25 06:16:28 -04:00
|
|
|
else
|
2021-01-05 07:24:10 -05:00
|
|
|
while /\A-/ =~ ARGV[0]
|
|
|
|
case ARGV[0]
|
|
|
|
when "-e"
|
|
|
|
edit = true
|
|
|
|
ARGV.shift
|
|
|
|
when "-a"
|
|
|
|
auto = true
|
|
|
|
ARGV.shift
|
2021-01-11 19:56:58 -05:00
|
|
|
else
|
|
|
|
$stderr.puts "Unknown command line option: #{ARGV[0]}"
|
|
|
|
exit 1
|
2021-01-05 07:24:10 -05:00
|
|
|
end
|
2020-07-12 10:40:27 -04:00
|
|
|
end
|
2020-07-05 11:33:03 -04:00
|
|
|
gem = ARGV.shift
|
|
|
|
if ARGV[0]
|
2020-07-12 10:40:27 -04:00
|
|
|
sync_default_gems_with_commits(gem, ARGV, edit: edit)
|
2021-01-05 07:24:10 -05:00
|
|
|
elsif auto
|
|
|
|
sync_default_gems_with_commits(gem, true, edit: edit)
|
2019-07-14 03:56:39 -04:00
|
|
|
else
|
2020-07-05 11:33:03 -04:00
|
|
|
sync_default_gems(gem)
|
2019-07-14 03:56:39 -04:00
|
|
|
end
|
2017-06-28 06:18:03 -04:00
|
|
|
end
|