diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-10-07 22:36:32 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-10-07 22:36:32 +0900 |
| commit | a6938eb46a10021642213b98d648544129a7dbb3 (patch) | |
| tree | 035a5146c82db296c124dc732251180f5c9d14d5 | |
| parent | 25c893af6d9a788f0c049b320418ec006f4aa869 (diff) | |
Skip files that are "deleted by us"
"Deleted" means that file is only for the upstream but not for ruby.
| -rwxr-xr-x | tool/sync_default_gems.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 366f64ddfc..1f6ae06b61 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -83,6 +83,10 @@ module SyncDefaultGems end end + def porcelain_status(*pattern) + pipe_readlines(%W"git status --porcelain -z --" + pattern) + end + def replace_rdoc_ref(file) src = File.binread(file) changed = false @@ -101,7 +105,7 @@ module SyncDefaultGems end def replace_rdoc_ref_all - result = pipe_readlines(%W"git status --porcelain -z -- *.c *.rb *.rdoc") + result = porcelain_status("*.c", "*.rb", "*.rdoc") result.map! {|line| line[/\A.M (.*)/, 1]} result.compact! return if result.empty? @@ -489,14 +493,16 @@ module SyncDefaultGems def resolve_conflicts(gem, sha, edit) # Skip this commit if everything has been removed as `ignored_paths`. - changes = pipe_readlines(%W"git status --porcelain -z") + changes = porcelain_status() if changes.empty? puts "Skip empty commit #{sha}" return false end - # We want to skip DD: deleted by both. - deleted = changes.grep(/^DD /) {$'} + # We want to skip + # DD: deleted by both + # DU: deleted by us + deleted = changes.grep(/^D[DU] /) {$'} system(*%W"git rm -f --", *deleted) unless deleted.empty? # Import UA: added by them @@ -505,10 +511,9 @@ module SyncDefaultGems # Discover unmerged files # AU: unmerged, added by us - # DU: unmerged, deleted by us # UU: unmerged, both modified # AA: unmerged, both added - conflict = changes.grep(/\A(?:.U|AA) /) {$'} + conflict = changes.grep(/\A(?:A[AU]|UU) /) {$'} # If -e option is given, open each conflicted file with an editor unless conflict.empty? if edit @@ -624,6 +629,8 @@ module SyncDefaultGems # Commit cherry-picked commit if picked system(*%w"git commit --amend --no-edit") + elsif porcelain_status().empty? + system(*%w"git cherry-pick --skip") else system(*%w"git cherry-pick --continue --no-edit") end or return nil |
