tubaguy50035 tubaguy50035 - 1 year ago 57
Ruby Question

Get latest git tag in Ruby for use with Capifony

I've followed this for several of our projects. It works wonderfully, except grabbing the latest git tag. For example, if I have tags 1,2,3,4,5,6,7,8,9,10, Capifony will try to deploy tag 9 because it sees that as the latest tag using the code provided on that how-to.

How can I change the following line to always get the latest tag?

set :branch, `git tag`.split("\n").last

tjd tjd
Answer Source

The output of git tag is alphabetical. How 'bout git tag | sort -n?

Alternatively you could perform a numeric sort on the result of the split before grabbing the last entry.