Check for folder in sync_default_gems (#15933)

It was not clear to me that you have to do anything for this command to work.
Previous versions (for example on the 3.4 branch) had this check
but it got lost along the way.

Without this when the folder doesn't exist, you get this error (after it deleted all the files):
```
$ ./tool/sync_default_gems.rb syntax_suggest
Sync ruby/syntax_suggest
./tool/sync_default_gems.rb:464:in 'SyncDefaultGems.check_prerelease_version': undefined method 'version' for nil (NoMethodError)

    puts "#{gem}-#{spec.version} is not latest version of rubygems.org" if spec.version.to_s != latest_version
                                                                               ^^^^^^^^
        from ./tool/sync_default_gems.rb:436:in 'SyncDefaultGems.sync_default_gems'
        from ./tool/sync_default_gems.rb:942:in '<module:SyncDefaultGems>'
        from ./tool/sync_default_gems.rb:10:in '<main>'
```

Now you get

```
$ ./tool/sync_default_gems.rb syntax_suggest
Sync ruby/syntax_suggest
Expected '../ruby/syntax_suggest' (/home/earlopain/Documents/ruby/syntax_suggest)  to be a directory, but it didn't exist.
```

This was changed in b722631b48

Since then, `sync_lib` is unused, delete it
This commit is contained in:
Earlopain 2026-01-22 19:20:28 +01:00 committed by GitHub
parent fd7bf518a6
commit 253bfd7d09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2026-01-22 18:20:59 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>

View File

@ -398,6 +398,10 @@ module SyncDefaultGems
upstream = File.join("..", "..", config.upstream) upstream = File.join("..", "..", config.upstream)
unless File.exist?(upstream)
abort %[Expected '#{upstream}' (#{File.expand_path("#{upstream}")}) to be a directory, but it didn't exist.]
end
config.mappings.each do |src, dst| config.mappings.each do |src, dst|
rm_rf(dst) rm_rf(dst)
end end
@ -798,26 +802,6 @@ module SyncDefaultGems
return true return true
end end
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.]
end
rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"])
cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
tests = if File.directory?("test/#{repo}")
"test/#{repo}"
else
"test/test_#{repo}.rb"
end
cp_r("#{upstream}/#{tests}", "test") if File.exist?("#{upstream}/#{tests}")
gemspec = if File.directory?("lib/#{repo}")
"lib/#{repo}/#{repo}.gemspec"
else
"lib/#{repo}.gemspec"
end
cp_r("#{upstream}/#{repo}.gemspec", "#{gemspec}")
end
def update_default_gems(gem, release: false) def update_default_gems(gem, release: false)
config = REPOSITORIES[gem] config = REPOSITORIES[gem]
author, repository = config.upstream.split('/') author, repository = config.upstream.split('/')