Skip to content

Commit 092f666

Browse files
committed
Skip files that are "deleted by us"
1 parent 25c893a commit 092f666

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

tool/sync_default_gems.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def pipe_readlines(args, rs: "\0", chomp: true)
8383
end
8484
end
8585

86+
def porcelain_status(*pattern)
87+
pipe_readlines(%W"git status --porcelain -z --" + pattern)
88+
end
89+
8690
def replace_rdoc_ref(file)
8791
src = File.binread(file)
8892
changed = false
@@ -101,7 +105,7 @@ def replace_rdoc_ref(file)
101105
end
102106

103107
def replace_rdoc_ref_all
104-
result = pipe_readlines(%W"git status --porcelain -z -- *.c *.rb *.rdoc")
108+
result = porcelain_status("*.c", "*.rb", "*.rdoc")
105109
result.map! {|line| line[/\A.M (.*)/, 1]}
106110
result.compact!
107111
return if result.empty?
@@ -489,14 +493,16 @@ def commits_in_ranges(gem, repo, default_branch, ranges)
489493

490494
def resolve_conflicts(gem, sha, edit)
491495
# Skip this commit if everything has been removed as `ignored_paths`.
492-
changes = pipe_readlines(%W"git status --porcelain -z")
496+
changes = porcelain_status()
493497
if changes.empty?
494498
puts "Skip empty commit #{sha}"
495499
return false
496500
end
497501

498-
# We want to skip DD: deleted by both.
499-
deleted = changes.grep(/^DD /) {$'}
502+
# We want to skip
503+
# DD: deleted by both
504+
# DU: deleted by us
505+
deleted = changes.grep(/^D[DU] /) {$'}
500506
system(*%W"git rm -f --", *deleted) unless deleted.empty?
501507

502508
# Import UA: added by them
@@ -505,10 +511,9 @@ def resolve_conflicts(gem, sha, edit)
505511

506512
# Discover unmerged files
507513
# AU: unmerged, added by us
508-
# DU: unmerged, deleted by us
509514
# UU: unmerged, both modified
510515
# AA: unmerged, both added
511-
conflict = changes.grep(/\A(?:.U|AA) /) {$'}
516+
conflict = changes.grep(/\A(?:A[AU]|UU) /) {$'}
512517
# If -e option is given, open each conflicted file with an editor
513518
unless conflict.empty?
514519
if edit
@@ -624,6 +629,8 @@ def pickup_commit(gem, sha, edit)
624629
# Commit cherry-picked commit
625630
if picked
626631
system(*%w"git commit --amend --no-edit")
632+
elsif porcelain_status().empty?
633+
system(*%w"git cherry-pick --skip")
627634
else
628635
system(*%w"git cherry-pick --continue --no-edit")
629636
end or return nil

0 commit comments

Comments
 (0)