Sha256: ef5fab17957ab9974bf79af21bbe60c2fd10632fee849c386b815ced43e5aabc

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Astrovan
  module Update
    # Update the application from git, then create a symlink to the current release.
    #
    # Options:
    # * +git+ - path to git tool. Default is 'git'
    def update(options = {})
      shared_repository = self.shared_repository
      repository = self.repository
      release_path = self.release_path
      current_path = self.current_path

      git  = options[:git] || self.git

      # TODO: should we also checkout to branch instead of using detached HEAD?
      exec <<-END, options
        if [ -d '#{shared_repository}' ]
        then
          cd #{shared_repository} &&
          #{git} fetch #{repository}
        else
          #{git} clone --bare #{repository} #{shared_repository}
        fi &&
        #{git} clone #{shared_repository} #{release_path} &&
        cd #{release_path} &&
        #{git} submodule init &&
        #{git} submodule update

      END

      symlink release_path, options.merge(:to => current_path)

      yield if block_given?
    rescue => e
      # TODO: rollback
      # rollback
      raise
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sbfaulkner-astrovan-0.6.0 lib/astrovan/update.rb