From 6a6dacb0d1ce47d413d75b6e45d07a8b08ace3fb Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 17 Aug 2023 22:04:24 -0700 Subject: [PATCH] Attempt to recover from YARP sync failures --- tool/sync_default_gems.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 91d326161d..242bbc07f2 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -571,19 +571,30 @@ module SyncDefaultGems if result.empty? skipped = true elsif /^CONFLICT/ =~ result - # Automatically fix some parts of conflicts + # Forcibly remove any files that we don't want to copy to this repository. + # We also ignore them as new `toplevels` even when they don't conflict. case gem when "rubygems" - # git doesn't auto-rename new files under the vcr_cassettes to spec/bundler. - # We delete them as `toplevels` if they don't conflict. + # We don't copy any vcr_cassettes to this repository. Because the directory does not + # exist, rename detection doesn't work. So it starts with the original path `bundler/`. %w[bundler/spec/support/artifice/vcr_cassettes].each do |rem| if File.exist?(rem) system("git", "reset", rem) rm_rf(rem) end end - # New files renamed to spec/bundler are safe to commit. + end + + # git has inexact rename detection, so they follow directory renames even for new files. + # However, new files are considered a `CONFLICT (file location)`, so you need to git-add them here. + # We hope that they are not other kinds of conflicts, assuming we don't modify them in this repository. + case gem + when "rubygems" system(*%w[git add spec/bundler]) + when "yarp" + system(*%w[git add lib/yarp]) + system(*%w[git add test/yarp]) + system(*%w[git add yarp]) end # Discover unmerged files