summaryrefslogtreecommitdiff
path: root/tool/sync_default_gems.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-08-29 11:51:05 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-08-29 11:51:05 +0200
commit232d6c4077ab254b13ef006dd1e7e7c1d46a6cd3 (patch)
treec8ddadecb785001fa6f4907fa7315f72946056b0 /tool/sync_default_gems.rb
parent6d946665bd79a93fb98b2d25400d1b6174472302 (diff)
Use a constant instead of a global variable in sync_default_gems.rb
Diffstat (limited to 'tool/sync_default_gems.rb')
-rw-r--r--tool/sync_default_gems.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index c2ebd39e82..663f54bed9 100644
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -3,7 +3,7 @@
require 'fileutils'
include FileUtils
-$repositories = {
+REPOSITORIES = {
rubygems: 'rubygems/rubygems',
bundler: 'rubygems/rubygems',
rdoc: 'ruby/rdoc',
@@ -70,9 +70,9 @@ $repositories = {
}
def sync_default_gems(gem)
- puts "Sync #{$repositories[gem.to_sym]}"
+ puts "Sync #{REPOSITORIES[gem.to_sym]}"
- upstream = File.join("..", "..", $repositories[gem.to_sym])
+ upstream = File.join("..", "..", REPOSITORIES[gem.to_sym])
case gem
when "rubygems"
@@ -292,11 +292,11 @@ IGNORE_FILE_PATTERN =
)\z/x
def sync_default_gems_with_commits(gem, ranges, edit: nil)
- puts "Sync #{$repositories[gem.to_sym]} with commit history."
+ puts "Sync #{REPOSITORIES[gem.to_sym]} 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:#{REPOSITORIES[gem.to_sym]}.git`
end
end
system(*%W"git fetch --no-tags #{gem}")
@@ -326,7 +326,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 #{REPOSITORIES[gem.to_sym]}."
skipped = false
result = IO.popen(%W"git cherry-pick #{sha}", &:read)
@@ -371,8 +371,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]}"
+ 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}"
@@ -408,7 +408,7 @@ end
def update_default_gems(gem)
- author, repository = $repositories[gem.to_sym].split('/')
+ author, repository = REPOSITORIES[gem.to_sym].split('/')
puts "Update #{author}/#{repository}"
@@ -439,14 +439,14 @@ when "up"
if ARGV[1]
update_default_gems(ARGV[1])
else
- $repositories.keys.each{|gem| update_default_gems(gem.to_s)}
+ REPOSITORIES.keys.each{|gem| update_default_gems(gem.to_s)}
end
when "all"
- $repositories.keys.each{|gem| sync_default_gems(gem.to_s)}
+ REPOSITORIES.keys.each{|gem| sync_default_gems(gem.to_s)}
when "list"
ARGV.shift
pattern = Regexp.new(ARGV.join('|'))
- $repositories.each_pair do |name, gem|
+ REPOSITORIES.each_pair do |name, gem|
next unless pattern =~ name or pattern =~ gem
printf "%-15s https://github.com/%s\n", name, gem
end