I wrote this task to prompt for a git branch or tag to deploy. I'm pretty 
new to RoR and Capistrano so I'd welcome any critique. And, maybe this will 
be useful for others.

I have this at the end of my Capfile:


Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }


I put this in file lib/capistrano/tasks/git_tasks.rake


desc "Prompt for branch or tag"
task git_branch_or_tag: :'git:wrapper' do
  on roles(:all) do |host|

    tags = "<none>"
    within repo_path do
      with fetch(:git_environmental_variables) do
        tags = capture(:git, :tag).split.join(', ')
      end
    end

    run_locally do
      tag_prompt = "Enter a branch or tag name to deploy, available tags 
include #{tags}"

      ask(:branch_or_tag, tag_prompt)
      tag_branch_target = fetch(:branch_or_tag)

      execute "echo \"About to deploy branch or tag 
'#{tag_branch_target}'\""
      set(:branch, tag_branch_target)
    end

  end
end

before 'deploy:starting', :git_branch_or_tag 



Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/7b0c649f-5e89-41c0-87f2-edf9559b612f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to