module Capistrano::Napkin::Utilities
Public Instance Methods
available_releases()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 49 def available_releases puts "\nAvailable Releases:".color :green puts "#{releases.reverse.take(Capistrano::Napkin::Configuration.previous_releases.to_i).join("\n")}" puts "\n" end
branches()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 27 def branches `git branch --no-color`.split("\n") end
current_branch()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 23 def current_branch branches.select{|b| b =~ /^\*\s/}.first.gsub(/^\*\s/,"") end
deploy_from()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 64 def deploy_from puts banner unless Capistrano::Napkin::Configuration.prude.to_i == 1 if fetch(:stage) == :production available_releases set :from_destination, ask("\nRelease to deploy:".color(:yellow).bright, latest_release) else set :create_tag, ask("\nDo you want to tag deployment?".color(:yellow).bright, 'N') return next_tag if fetch(:create_tag).downcase =~ /^[Yy]$/ available_tags set :from_destination, ask("\nBranch, tag or release to deploy:".color(:yellow).bright, current_branch) end return fetch(:from_destination) end
latest_release()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 39 def latest_release releases.reverse.first.to_s end
next_tag()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 78 def next_tag hwhen = Date.today.to_s set :what, ask("\nWhat does this release introduce?".color(:yellow).bright, nil) new_staging_tag = "#{hwhen}-#{who}-#{fetch(:what)}" puts "Tagging current branch for deployment to staging as '#{new_staging_tag}'".color(:green) system "git tag -a -m 'tagging current code for deployment to staging' #{new_staging_tag}" return new_staging_tag end
releases()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 35 def releases tags.select{|t| t =~ /^#{version_tag_prefix}(\d+)/}.collect{|version| Versionomy.parse(version) }.sort end
using_git?()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 87 def using_git? fetch(:scm, :git).to_sym == :git end
version_tag_prefix()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 31 def version_tag_prefix `git config gitflow.prefix.versiontag`.split("\n").first end
who()
click to toggle source
# File lib/capistrano/napkin/utilities.rb, line 10 def who identity = (`git config user.name` || `whoami`) identity.chomp.to_url end