Skip to content

Instantly share code, notes, and snippets.

@zmoazeni
Created December 19, 2008 18:27
Show Gist options
  • Save zmoazeni/38071 to your computer and use it in GitHub Desktop.
Save zmoazeni/38071 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "fileutils"
@current_path = File.dirname(__FILE__)
def database_config(branch)
"#{current_path}/../database_configs/#{branch}.yml"
end
def current_path
@current_path
end
new_ref = ARGV[1]
if new_ref
new_branch = `git name-rev #{new_ref}`.split[1]
return unless new_branch
if File.exist?(database_config(new_branch))
puts "#{File.basename(__FILE__)}: Symlinking database config for #{new_branch}"
FileUtils.ln_sf database_config(new_branch), "#{@current_path}/../../config/database.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment