Skip to content

Commit 253bfd7

Browse files
authored
Check for folder in sync_default_gems (ruby#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 ruby@b722631 Since then, `sync_lib` is unused, delete it
1 parent fd7bf51 commit 253bfd7

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

tool/sync_default_gems.rb

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ def sync_default_gems(gem)
398398

399399
upstream = File.join("..", "..", config.upstream)
400400

401+
unless File.exist?(upstream)
402+
abort %[Expected '#{upstream}' (#{File.expand_path("#{upstream}")}) to be a directory, but it didn't exist.]
403+
end
404+
401405
config.mappings.each do |src, dst|
402406
rm_rf(dst)
403407
end
@@ -798,26 +802,6 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
798802
return true
799803
end
800804

801-
def sync_lib(repo, upstream = nil)
802-
unless upstream and File.directory?(upstream) or File.directory?(upstream = "../#{repo}")
803-
abort %[Expected '#{upstream}' \(#{File.expand_path("#{upstream}")}\) to be a directory, but it wasn't.]
804-
end
805-
rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"])
806-
cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
807-
tests = if File.directory?("test/#{repo}")
808-
"test/#{repo}"
809-
else
810-
"test/test_#{repo}.rb"
811-
end
812-
cp_r("#{upstream}/#{tests}", "test") if File.exist?("#{upstream}/#{tests}")
813-
gemspec = if File.directory?("lib/#{repo}")
814-
"lib/#{repo}/#{repo}.gemspec"
815-
else
816-
"lib/#{repo}.gemspec"
817-
end
818-
cp_r("#{upstream}/#{repo}.gemspec", "#{gemspec}")
819-
end
820-
821805
def update_default_gems(gem, release: false)
822806
config = REPOSITORIES[gem]
823807
author, repository = config.upstream.split('/')

0 commit comments

Comments
 (0)