Created
May 10, 2011 12:00
-
-
Save jamiecobbett/964343 to your computer and use it in GitHub Desktop.
Capistrano: prompt to confirm branch if not on master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_git_branch | |
`git symbolic-ref HEAD`.gsub("refs/heads/", "") | |
end | |
def prompt_with_default(message, default) | |
response = Capistrano::CLI.ui.ask "#{message} Default is: [#{default}] : " | |
response.empty? ? default : response | |
end | |
def set_branch | |
if current_git_branch != "master" | |
set :branch, ENV['BRANCH'] || prompt_with_default("Enter branch to deploy, or ENTER for default.", "master") | |
else | |
set :branch, ENV['BRANCH'] || "master" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment