Module: Capistrano::Tampon::Utilities
- Defined in:
- lib/capistrano/tampon/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
48 49 50 51 |
# File 'lib/capistrano/tampon/utilities.rb', line 48 def available_releases puts "\nAvailable Releases:".color :green puts "#{releases.reverse.take(Capistrano::Tampon::Configuration.previous_releases.to_i).join("\n")}" end |
#available_tags ⇒ Object
43 44 45 46 |
# File 'lib/capistrano/tampon/utilities.rb', line 43 def puts "Available Tags:".color :green puts "#{releases.sort.reverse.take(Capistrano::Tampon::Configuration.previous_releases.to_i).join("\n")}" end |
#banner ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capistrano/tampon/utilities.rb', line 53 def <<-BANNER \nTampon for Gitflow ,-------------. (o) _ __ _____ )--. `-------------' ) ( / `---' BANNER end |
#branches ⇒ Object
27 28 29 |
# File 'lib/capistrano/tampon/utilities.rb', line 27 def branches `git branch --no-color`.split("\n") end |
#current_branch ⇒ Object
23 24 25 |
# File 'lib/capistrano/tampon/utilities.rb', line 23 def current_branch branches.select{|b| b =~ /^\*\s/}.first.gsub(/^\*\s/,"") end |
#deploy_from ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/capistrano/tampon/utilities.rb', line 67 def deploy_from puts unless Capistrano::Tampon::Configuration.prude.to_i == 1 if stage == :production available_releases from_destination = ask("\nRelease to deploy:".color(:yellow).bright, lastest_release) else create_tag = ask("Do you want to tag deployment? [y/N]".color(:yellow), 'N') return next_tag if create_tag from_destination = ask "\nBranch, tag or release to deploy:".color(:yellow).bright, current_branch end return from_destination end |
#latest_release ⇒ Object
39 40 41 |
# File 'lib/capistrano/tampon/utilities.rb', line 39 def latest_release releases.reverse.first.to_s end |
#next_tag ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/capistrano/tampon/utilities.rb', line 81 def next_tag hwhen = Date.today.to_s what = ask("What does this release introduce? (this will be normalized and used in the tag for this release)".color(:yellow)).to_url new_staging_tag = "#{hwhen}-#{who}-#{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/tampon/utilities.rb', line 19 def - releases end |
#releases ⇒ Object
35 36 37 |
# File 'lib/capistrano/tampon/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/tampon/utilities.rb', line 15 def `git tag`.split("\n").compact end |
#using_git? ⇒ Boolean
90 91 92 |
# File 'lib/capistrano/tampon/utilities.rb', line 90 def using_git? fetch(:scm, :git).to_sym == :git end |
#version_tag_prefix ⇒ Object
31 32 33 |
# File 'lib/capistrano/tampon/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/tampon/utilities.rb', line 10 def who identity = (`git config user.name` || `whoami`) identity.chomp.to_url end |