Divergence

Switch branches as fast as you switch pages. Waiting for a deploy sucks. Allocating a staging server for each remote branch is costly. But nothing beats testing on a staging server with real production data. Divergence allows you to quickly test your remote branches simply by changing the subdomain.

How it works

Divergence allows you to easily view any branch from your repository by using the branch name as the subdomain. Replace invalid URL characters with dashes and Divergence will magically find the branch you're looking for. Hook into one or many callbacks to automatically restart Passenger or run a bundle install if needed.

http://branchname.yourdomain.com

Running Divergence is simple. Install the gem, initialize it into a folder, set your application paths in the config, and start it. You may have to make a quick DNS change as well for the best results. It works best when you give it its own domain, like layervault-divergence.com

Depending on your setup, some more configuration may be required. Divergence was built with an Apache-Passenger stack in mind. If you want to develop the project further, please see the Contributing section. Our team is eager to see where Divergence goes.

More in-depth instructions on running and configuration, as well as the Divergence source code, are available on GitHub.

Installation

Divergence lives on RubyGems. Simply run:

gem install divergence

After installation finishes, move to an empty directory and run:

divergence init

Configuration

Each project is going to be a bit different, that's why we've made Divergence highly configurable. First, you will need to point Divergence where to look. Here's an example config/config:

# config/config.rb

require File.expand_path('../callbacks', __FILE__)

Divergence::Application.configure do |config|
  # Change this to the git repository path
  config.git_path = "/var/www/web_app/repository"

  # this to your application's path
  config.app_path = "/var/www/web_app/current"

  # and this to a location for the cache
  config.cache_path = "/var/www/web_app/cache"

  config.forward_host = 'localhost'
  config.forward_port = 81
end

There are also a suite of callbacks at your disposal. Please see the GitHub project page for a list. Here's an example of our :after_swap callback:

# config/callbacks.rb

Divergence::Application.configure do |config|
  config.callbacks :after_cache, :after_webhook do
    # This is a built-in helper method
    bundle_install
  end
end

Contributing

Download .zip Download .tar.gz View on GitHub

Next up

Divergence is a work in progress. This is a beta release. There are a few things that we could use a hand with, including:

If you'd like to tackle these things, fork it up and issue us a Pull Request.

Credit

Ryan LeFevre
Kelly Sutton
Allan Grinshtein

License

Copyright 2013 LayerVault Inc.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.