nfm
nfm

Reputation: 20687

How can I print my git tags in Capistrano as part of my deploy task?

I've set up Capistrano to ask me which git tag I want to deploy:

# deploy.rb
set(:branch) { Capistrano::CLI.ui.ask('Tag to deploy:') }

This works as expected - if I specify v0.75 it will deploy that tag.

However, I'd love it if I could print out the list of my tags before I get asked which one to deploy, with something like this:

git tag -n | tac | head -n 10

How can I execute and print the result of the above shell command in capistrano, before being prompted for the tag to deploy?

Upvotes: 1

Views: 902

Answers (1)

nfm
nfm

Reputation: 20687

Turns out that there's no magic required. The following will do it nicely:

set :branch do
  puts `git tag -n | tac | head -n 10`
  Capistrano::CLI.ui.ask('Tag to deploy:')
end

Upvotes: 2

Related Questions