Skip to content

Commit

Permalink
Skip the some of commits when sync default gems from upstream.
Browse files Browse the repository at this point in the history
  * Skip failed to sync commits because it needs to pick manually.
  * Skip empty commit.
  • Loading branch information
hsbt committed Jul 27, 2019
1 parent 012d39c commit 58bb7f0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tool/sync_default_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,30 @@ def sync_default_gems_with_commits(gem, range)
puts commits.map{|commit| commit.join(": ")}.join("\n")
puts "----"

failed_commits = []

commits.each do |sha, subject|
puts "Pick #{sha} from #{$repositories[gem.to_sym]}."

`git cherry-pick #{sha}`
unless $?.success?
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}"
end
next if skipped

if result.empty?
failed_commits << sha
`git reset` && `git checkout .` && `git clean -fd`
skipped = true
puts "Failed to pick #{sha}"
break
end
next if skipped

puts "Update commit message: #{sha}"

prefix = "[#{($repositories[gem.to_sym])}]".gsub(/\//, '\/')
suffix = "https://github.com/#{($repositories[gem.to_sym])}/commit/#{sha[0,10]}"
`git filter-branch -f --msg-filter 'sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD`
Expand All @@ -275,6 +291,8 @@ def sync_default_gems_with_commits(gem, range)
break
end
end

puts failed_commits
end

def sync_lib(repo)
Expand Down

0 comments on commit 58bb7f0

Please sign in to comment.