I tried this in Capistrano 3.3.3 but after I added the tag number, it stopped and did not run further.
def tag_branch_target tags = `git tag`.split("\n") tag_prompt = "\nlast tags available are #{tags.reverse[(0..5)]}" ask :branch_or_tag, tag_prompt tag = fetch(:branch_or_tag) tag.match(/^\d/).nil? ? tags.last : tag end set :branch, proc { tag_branch_target } It looks sth like: NFO[edfd8380] Running /usr/bin/env chmod +x /tmp/ace/git-ssh.sh on 10.10. 82.31 DEBUG[edfd8380] Command: /usr/bin/env chmod +x /tmp/ace/git-ssh.sh INFO[6d1eea4e] Finished in 0.168 seconds with exit status 0 (successful). INFO[edfd8380] Finished in 0.164 seconds with exit status 0 (successful). Please enter branch_or_tag ( last tags available are ["0.9.1", "0.9.0", "0.8.0", "0.7.9", "0.7.8", "0.7.7"]): if no tag is given, that last one is used. I really like the idea to put that into a capistrano rake task so if I find time I will work on it. On Monday, January 20, 2014 8:49:10 PM UTC+1, Lee Hambley wrote: > > Looks good Dave! > > Sent from my Nexus 4. > On 20 Jan 2014 17:14, "Dave Hamilton" <djhami...@gmail.com <javascript:>> > wrote: > >> 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 capistrano+...@googlegroups.com <javascript:>. >> 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. >> > -- 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 capistrano+unsubscr...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/b13459a4-ca82-433d-b59f-b8ad0f0ec3c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.