summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-05 21:23:07 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-05 21:23:07 +0900
commit075824ebd53932898015fa264c7b8b8804c946b0 (patch)
tree6f909bfe32f3346bc472ba29c9ab47dd3e8663f1 /tool
parent903af74bbd2998cbc159c70010fdba0543509a0f (diff)
sync_default_gems.rb: reduced accesses to REPOSITORIES
Diffstat (limited to 'tool')
-rw-r--r--tool/sync_default_gems.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index 620215067d..6db42b6dfc 100644
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -84,9 +84,10 @@ REPOSITORIES = {
}
def sync_default_gems(gem)
- puts "Sync #{REPOSITORIES[gem.to_sym]}"
+ repo = REPOSITORIES[gem.to_sym]
+ puts "Sync #{repo}"
- upstream = File.join("..", "..", REPOSITORIES[gem.to_sym])
+ upstream = File.join("..", "..", repo)
case gem
when "rubygems"
@@ -342,11 +343,12 @@ IGNORE_FILE_PATTERN =
)\z/x
def sync_default_gems_with_commits(gem, ranges, edit: nil)
- puts "Sync #{REPOSITORIES[gem.to_sym]} with commit history."
+ repo = REPOSITORIES[gem.to_sym]
+ puts "Sync #{repo} with commit history."
IO.popen(%W"git remote") do |f|
unless f.read.split.include?(gem)
- `git remote add #{gem} git@github.com:#{REPOSITORIES[gem.to_sym]}.git`
+ `git remote add #{gem} git@github.com:#{repo}.git`
end
end
system(*%W"git fetch --no-tags #{gem}")
@@ -376,7 +378,7 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
ENV["FILTER_BRANCH_SQUELCH_WARNING"] = "1"
commits.each do |sha, subject|
- puts "Pick #{sha} from #{REPOSITORIES[gem.to_sym]}."
+ puts "Pick #{sha} from #{repo}."
skipped = false
result = IO.popen(%W"git cherry-pick #{sha}", &:read)
@@ -421,9 +423,8 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil)
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 'grep "" - | sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD`
+ suffix = "https://github.com/#{repo}/commit/#{sha[0,10]}"
+ `git filter-branch -f --msg-filter 'grep "" - | sed "1s|^|[#{repo}] |" && echo && echo #{suffix}' -- HEAD~1..HEAD`
unless $?.success?
puts "Failed to modify commit message of #{sha}"
break