Class: Statistrano::Deployment::Strategy::Branches

Inherits:
Base
  • Object
show all
Defined in:
lib/statistrano/deployment/strategy/branches.rb,
lib/statistrano/deployment/strategy/branches/index.rb,
lib/statistrano/deployment/strategy/branches/release.rb

Overview

Branches is for deployments that depend upon the current git branch, eg. doing feature branch deployments

Defined Under Namespace

Classes: Index, Release

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#deploy, #flush_persisted_releaser!, #initialize, #log_file, #persisted_releaser, #register_tasks, #remotes

Methods included from Registerable

#register_strategy

Methods included from Config::Configurable

#configuration, extended, #inherited, #option, #options, #task, #validate

Methods included from CheckGit

#safe_to_deploy?

Methods included from InvokeTasks

#call_or_invoke_task, #invoke_build_task, #invoke_post_deploy_task, #invoke_pre_symlink_task

Constructor Details

This class inherits a constructor from Statistrano::Deployment::Strategy::Base

Instance Method Details

#generate_indexVoid

generate an index file for releases in the manifest

Returns:

  • (Void)


60
61
62
63
64
65
66
67
# File 'lib/statistrano/deployment/strategy/branches.rb', line 60

def generate_index
  remotes.each do |remote|
    index_dir  = File.join( remote.config.remote_dir, "index" )
    index_path = File.join( index_dir, "index.html" )
    remote.create_remote_dir index_dir
    remote.run "touch #{index_path} && echo '#{release_list_html(remote)}' > #{index_path}"
  end
end

#list_releasesVoid

output a list of the releases in manifest

Returns:

  • (Void)


30
31
32
33
34
35
36
37
38
# File 'lib/statistrano/deployment/strategy/branches.rb', line 30

def list_releases
  remotes.each do |remote|
    releases_data = sorted_release_data(remote)
    releases_data.map! do |release|
      "#{release[:name]} created at #{Time.at(release[:time]).strftime('%a %b %d, %Y at %l:%M %P')}"
    end
    Log.info remote.config.hostname.to_sym, *releases_data
  end
end

#prune_releasesVoid

trim releases not in the manifest, get user input for removal of other releases

Returns:

  • (Void)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/statistrano/deployment/strategy/branches.rb', line 43

def prune_releases
  candidate_releases = []
  remotes.each do |remote|
    prune_untracked_releases(remote)
    candidate_releases.push *get_releases(remote)
    candidate_releases.uniq!
  end

  if candidate_releases.length > 0
    pick_and_remove_release candidate_releases
  else
    Log.warn "no releases to prune"
  end
end

#push_current_release_to_manifestVoid

push the current release into the manifest

Returns:

  • (Void)


71
72
73
74
75
76
77
# File 'lib/statistrano/deployment/strategy/branches.rb', line 71

def push_current_release_to_manifest
  remotes.each do |remote|
    mnfst = manifest(remote)
    mnfst.put Release.new( config.public_dir, config ).to_hash, :name
    mnfst.save!
  end
end