summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-07-26 17:14:32 +0800
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-07-26 17:20:07 +0800
commit95aa60f6cde1ab7bc5cfe33c95c4fd2d2154cd52 (patch)
tree7a6eb84236eccce22de8aef228103abf179d93ba /tool
parent071bf889706d13879c323d61fd2e757ff32c8bda (diff)
Ignore Merge commit and insufficiency commit for ruby core repository.
Diffstat (limited to 'tool')
-rw-r--r--tool/sync_default_gems.rb46
1 files changed, 27 insertions, 19 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index 599d6b3281..cb9492f26e 100644
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -238,31 +238,39 @@ def sync_default_gems_with_commits(gem, range)
end
`git fetch --no-tags #{gem}`
+ commits = []
+
IO.popen(%W"git log --format=%H,%s #{range}") do |f|
commits = f.read.split("\n").reverse.map{|commit| commit.split(',')}
+ end
- # Ignore Merge commit for ruby core repository.
- commits.delete_if{|_, subject| subject =~ /^Merge/}
-
- puts "Try to pick these commits:"
- puts commits.map{|commit| commit.join(": ")}.join("\n")
+ # Ignore Merge commit and insufficiency commit for ruby core repository.
+ commits.delete_if do |sha, subject|
+ files = []
+ IO.popen(%W"git diff-tree --no-commit-id --name-only -r #{sha}") do |f|
+ files = f.read.split("\n")
+ end
+ subject =~ /^Merge/ || files.all?{|file| file =~ /(\.travis.yml|appveyor\.yml|azure\-pipelines\.yml|\.gitignore|Gemfile|README\.md)/}
+ end
- commits.each do |sha, subject|
- puts "Pick #{sha} from #{$repositories[gem.to_sym]}."
+ puts "Try to pick these commits:"
+ puts commits.map{|commit| commit.join(": ")}.join("\n")
+ puts "----"
- `git cherry-pick #{sha}`
- unless $?.success?
- puts "Failed to pick #{sha}"
- break
- end
+ commits.each do |sha, subject|
+ puts "Pick #{sha} from #{$repositories[gem.to_sym]}."
- 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`
- unless $?.success?
- puts "Failed to modify commit message of #{sha}"
- break
- end
+ `git cherry-pick #{sha}`
+ unless $?.success?
+ puts "Failed to pick #{sha}"
+ break
+ end
+ 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`
+ unless $?.success?
+ puts "Failed to modify commit message of #{sha}"
+ break
end
end
end