From 925ce3f4fbe2f05b8673a6dbc763ecab9f04fae1 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 21 Aug 2023 13:30:40 -0700 Subject: Skip commits that are empty after conflict resolution --- tool/sync_default_gems.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 9b9b0011ba..ce6a6dd0ae 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -558,16 +558,15 @@ module SyncDefaultGems puts "Pick #{sha} from #{repo}." # Attempt to cherry-pick a commit - skipped = false result = IO.popen(%W"git cherry-pick #{sha}", &:read) if result =~ /nothing\ to\ commit/ `git reset` - skipped = true puts "Skip empty commit #{sha}" + next end - next if skipped # Skip empty commits or deal with conflicts + skipped = false if result.empty? skipped = true elsif /^CONFLICT/ =~ result @@ -585,6 +584,7 @@ module SyncDefaultGems end ignored_paths.each do |path| if File.exist?(path) + puts "Removing: #{path}" system("git", "reset", path) rm_rf(path) end @@ -609,6 +609,12 @@ module SyncDefaultGems # UA: unmerged, added by them # AA: unmerged, both added unmerged = pipe_readlines(%W"git status --porcelain -z") + if unmerged.empty? + # Everything was removed as `ignored_paths`. Skip this commit. + `git reset` && `git checkout .` && `git clean -fd` + puts "Skip empty commit #{sha}" + next + end # For YARP, we want to handle DD: deleted by both. if gem == "yarp" -- cgit v1.2.3