diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-08-17 17:58:32 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-08-17 17:58:36 -0700 |
commit | ad2bad4ab42c490beca0bd3c5cd9846fdff238c2 (patch) | |
tree | 2ef7eef001458153a10171dab12e569d0cb89410 /tool | |
parent | 434cbc05f387616e1e4014a5942e265b7451ab08 (diff) | |
download | ruby-ad2bad4ab42c490beca0bd3c5cd9846fdff238c2.tar.gz |
Fix the scope of rubygems conflict resolution
The `git reset` and `rm_rf` are not necessary because `bundler/` is
considered as a `toplevels` and removed from the commit when there's
no conflict.
For conflict cases, it's useful to remove them from the conflict targets
before moving on to fix other paths.
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/sync_default_gems.rb | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index db458cc325..e94ce81d1f 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -563,20 +563,24 @@ module SyncDefaultGems end next if skipped - case gem - when "rubygems" - %w[bundler/spec/support/artifice/vcr_cassettes].each do |rem| - if File.exist?(rem) - system("git", "reset", rem) - rm_rf(rem) - end - end - system(*%w[git add spec/bundler]) - end - if result.empty? skipped = true elsif /^CONFLICT/ =~ result + # Automatically fix some parts of conflicts + 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. + %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. + system(*%w[git add spec/bundler]) + end + result = pipe_readlines(%W"git status --porcelain -z") result.map! {|line| line[/\A(?:.U|[UA]A) (.*)/, 1]} result.compact! |