Sha256: 755e81a5e98012c309f9ba8b56cfa49c0fa608a85f1bc5e7dafe29b4fb3d8b58

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

require 'colored' if Rails.env.development?

def run_with_clean_env(command, capture_output=false)
  Bundler.with_clean_env { capture_output ? `#{command}` : sh(command) }
end

namespace :integration do
  APP = ENV['STAGING_APP'] || ENV['APP']
  USER = run_with_clean_env("git config --get user.name", true).strip

  namespace :heroku do

    desc "Add Heroku git remotes"
    task :add_remote do
      puts "--> Adding Heroku git remotes for app #{APP}".magenta

      remote = run_with_clean_env("git remote | grep heroku", true).strip
      run_with_clean_env("git remote add heroku git@heroku.com:#{APP}.git") if remote.blank?
    end

    desc "Check if there's someone else integrating the project"
    task :check do
      puts "--> Checking if there's already someone integrating to #{APP}".magenta

      var = run_with_clean_env("heroku config -s --app #{APP} | grep INTEGRATING_BY", true).strip
      integrating_by = var.split('=')[1]

      integrating_by.strip! unless integrating_by.blank?

      if integrating_by != USER and not integrating_by.blank?
        puts "--> Project is already being integrated by '#{integrating_by}', halting"
        exit
      end
    end

    desc "Lock the Heroku integration"
    task :lock do
      puts "--> Locking Heroku integration for you (#{USER})".magenta
      run_with_clean_env("heroku config:set INTEGRATING_BY='#{USER}' --app #{APP}")
    end

    desc "Unlock the Heroku integration"
    task :unlock do
      puts "--> Unlocking Heroku integration".magenta
      run_with_clean_env("heroku config:unset INTEGRATING_BY --app #{APP}")
    end
  end
end

INTEGRATION_TASKS = %w(
  integration:heroku:add_remote
  integration:heroku:check
  integration:heroku:lock
  integration:start
  integration:bundle_install
  db:migrate
  spec
  integration:coverage_verify
  integration:finish
  heroku:deploy:staging
  integration:heroku:unlock
)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pah-0.0.9 lib/pah/files/lib/tasks/integration.rake
pah-0.0.8 lib/pah/files/lib/tasks/integration.rake
pah-0.0.7 lib/pah/files/lib/tasks/integration.rake