sync_default_gems.rb: reduced accesses to REPOSITORIES
This commit is contained in:
parent
903af74bbd
commit
075824ebd5
@ -84,9 +84,10 @@ REPOSITORIES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def sync_default_gems(gem)
|
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
|
case gem
|
||||||
when "rubygems"
|
when "rubygems"
|
||||||
@ -342,11 +343,12 @@ IGNORE_FILE_PATTERN =
|
|||||||
)\z/x
|
)\z/x
|
||||||
|
|
||||||
def sync_default_gems_with_commits(gem, ranges, edit: nil)
|
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|
|
IO.popen(%W"git remote") do |f|
|
||||||
unless f.read.split.include?(gem)
|
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
|
||||||
end
|
end
|
||||||
system(*%W"git fetch --no-tags #{gem}")
|
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"
|
ENV["FILTER_BRANCH_SQUELCH_WARNING"] = "1"
|
||||||
|
|
||||||
commits.each do |sha, subject|
|
commits.each do |sha, subject|
|
||||||
puts "Pick #{sha} from #{REPOSITORIES[gem.to_sym]}."
|
puts "Pick #{sha} from #{repo}."
|
||||||
|
|
||||||
skipped = false
|
skipped = false
|
||||||
result = IO.popen(%W"git cherry-pick #{sha}", &:read)
|
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}"
|
puts "Update commit message: #{sha}"
|
||||||
|
|
||||||
prefix = "[#{(REPOSITORIES[gem.to_sym])}]".gsub(/\//, '\/')
|
suffix = "https://github.com/#{repo}/commit/#{sha[0,10]}"
|
||||||
suffix = "https://github.com/#{(REPOSITORIES[gem.to_sym])}/commit/#{sha[0,10]}"
|
`git filter-branch -f --msg-filter 'grep "" - | sed "1s|^|[#{repo}] |" && echo && echo #{suffix}' -- HEAD~1..HEAD`
|
||||||
`git filter-branch -f --msg-filter 'grep "" - | sed "1s/^/#{prefix} /" && echo && echo #{suffix}' -- HEAD~1..HEAD`
|
|
||||||
unless $?.success?
|
unless $?.success?
|
||||||
puts "Failed to modify commit message of #{sha}"
|
puts "Failed to modify commit message of #{sha}"
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user