Module: Capistrano::Faucet::Utilities
- Defined in:
- lib/capistrano/faucet/utilities.rb
Instance Method Summary collapse
- #available_releases ⇒ Object
- #available_tags ⇒ Object
- #banner ⇒ Object
- #branches ⇒ Object
- #current_branch ⇒ Object
- #deploy_from ⇒ Object
- #latest_release ⇒ Object
- #next_tag ⇒ Object
- #non_release_tags ⇒ Object
- #releases ⇒ Object
- #tags ⇒ Object
- #using_git? ⇒ Boolean
- #version_tag_prefix ⇒ Object
- #who ⇒ Object
Instance Method Details
#available_releases ⇒ Object
49 50 51 52 53 |
# File 'lib/capistrano/faucet/utilities.rb', line 49 def available_releases puts "\nAvailable Releases:".color :green puts "#{releases.reverse.take(Capistrano::Faucet::Configuration.previous_releases.to_i).join("\n")}" puts "\n" end |
#available_tags ⇒ Object
43 44 45 46 47 |
# File 'lib/capistrano/faucet/utilities.rb', line 43 def puts "Available Tags:".color :green puts "#{releases.sort.reverse.take(Capistrano::Faucet::Configuration.previous_releases.to_i).join("\n")}" puts "\n" end |
#banner ⇒ Object
55 56 57 58 59 60 |
# File 'lib/capistrano/faucet/utilities.rb', line 55 def <<-BANNER \n Faucet for Gitflow BANNER end |
#branches ⇒ Object
27 28 29 |
# File 'lib/capistrano/faucet/utilities.rb', line 27 def branches `git branch --no-color`.split("\n") end |
#current_branch ⇒ Object
23 24 25 |
# File 'lib/capistrano/faucet/utilities.rb', line 23 def current_branch branches.select{|b| b =~ /^\*\s/}.first.gsub(/^\*\s/,"") end |
#deploy_from ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/capistrano/faucet/utilities.rb', line 64 def deploy_from puts unless Capistrano::Faucet::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]$/ set :from_destination, ask("\nBranch, tag or release to deploy:".color(:yellow).bright, current_branch) end return fetch(:from_destination) end |
#latest_release ⇒ Object
39 40 41 |
# File 'lib/capistrano/faucet/utilities.rb', line 39 def latest_release releases.reverse.first.to_s end |
#next_tag ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/capistrano/faucet/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 |
#non_release_tags ⇒ Object
19 20 21 |
# File 'lib/capistrano/faucet/utilities.rb', line 19 def - releases end |
#releases ⇒ Object
35 36 37 |
# File 'lib/capistrano/faucet/utilities.rb', line 35 def releases .select{|t| t =~ /^#{version_tag_prefix}(\d+)/}.collect{|version| Versionomy.parse(version) }.sort end |
#tags ⇒ Object
15 16 17 |
# File 'lib/capistrano/faucet/utilities.rb', line 15 def `git tag`.split("\n").compact end |
#using_git? ⇒ Boolean
87 88 89 |
# File 'lib/capistrano/faucet/utilities.rb', line 87 def using_git? fetch(:scm, :git).to_sym == :git end |
#version_tag_prefix ⇒ Object
31 32 33 |
# File 'lib/capistrano/faucet/utilities.rb', line 31 def version_tag_prefix `git config gitflow.prefix.versiontag`.split("\n").first end |
#who ⇒ Object
10 11 12 13 |
# File 'lib/capistrano/faucet/utilities.rb', line 10 def who identity = (`git config user.name` || `whoami`) identity.chomp.to_url end |