From 3c9405a323c54566a8bd041f09ee47b3a2393ae9 Mon Sep 17 00:00:00 2001 From: Trey Dempsey Date: Wed, 26 Jun 2013 19:29:44 -0500 Subject: [PATCH] * Allow passing tag=... on the command line for non-interactive deployments. * Updated documentation. --- README.markdown | 3 +++ lib/capistrano/deployflow.rb | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 6b74e7a..0b75d59 100644 --- a/README.markdown +++ b/README.markdown @@ -82,6 +82,9 @@ you have to do is `cap production deploy`, and deployflow will ask which tag you your most recent automatically), merge that tag over to your master branch, push to origin, and deploy that tag to production. +For non-interactive deployments you can also specify the tag with tag="tag name". For example you can do +`cap production deploy tag=production_20130626`. + Credits ------- diff --git a/lib/capistrano/deployflow.rb b/lib/capistrano/deployflow.rb index 0a8c1da..5b223e8 100644 --- a/lib/capistrano/deployflow.rb +++ b/lib/capistrano/deployflow.rb @@ -14,14 +14,16 @@ def most_recent_tag end def ask_which_tag - tag = Capistrano::CLI.ui.ask("What tag would you like to promote to #{stage}? [#{most_recent_tag}]") - if tag == "" - promote_tag = most_recent_tag + if ENV['tag'] + promote_tag = ENV['tag'] else - # Do we have this tag? - abort "Tag '#{tag}' does not exist!" unless `git tag`.split(/\n/).include?(tag) - promote_tag = tag + tag = Capistrano::CLI.ui.ask("What tag would you like to promote to #{stage}? [#{most_recent_tag}]") + promote_tag = tag == "" ? most_recent_tag : tag end + + # Do we have this tag? + abort "Tag '#{promote_tag}' does not exist!" unless `git tag`.split(/\n/).include?(promote_tag) + puts "Promoting #{promote_tag} to #{stage}." return promote_tag end