Initial public import
A viewable MIME type was not detected. Trying to display the file content as plain text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#!/usr/bin/env ruby
#--
# Copyright (C) 2007 Dimitrij Denissenko
# Please read LICENSE document for more information.
#++
require 'optparse'
OPTIONS = {
:environment => "production",
:reload_db => false,
:dry_run => false,
:truncate_db => false
}
ARGV.options do |opts|
script_name = File.basename($0)
opts.banner = "Usage: ruby #{script_name} [options]"
opts.separator ""
opts.on("-t", "--truncate-db",
"resync the entire database, truncating it first") { |OPTIONS[:truncate_db]| }
opts.on("-e", "--environment=name", String,
"Specifies the environment to run this script against",
"(test/development/production). Default: production") { |OPTIONS[:environment]| }
opts.on("-d", "--dry-run",
"Doesn't insert anything into the database") { |OPTIONS[:dry_run]| }
opts.separator ''
opts.on("-h", "--help",
"Show this help message.") { puts opts; exit }
opts.parse!
end
# Set up our environment
ENV["RAILS_ENV"] = OPTIONS[:environment]
require File.dirname(__FILE__) + '/../config/environment'
if OPTIONS[:dry_run]
puts '*' * 50
puts ' ' * 10 + 'THIS IS JUST A DRY RUN!'
puts '*' * 50
end
# Truncate the tables if requested
if OPTIONS[:truncate_db]
unless OPTIONS[:dry_run]
Changeset.destroy_all
end
puts ">>> Truncated 'changesets' and 'changes' tables <<<"
end
# Reset column info
Change.reset_column_information
Changeset.reset_column_information
Repository.reset_column_information
# The actual sync stuff
Repository.find(:all).each do |repos|
puts ">>> Synching repository '#{repos.name}' <<<"
unless OPTIONS[:dry_run]
repos.sync_changesets rescue puts($!)
end
end |
|---|