Class: Rake::Delphi::Git
- Inherits:
-
Object
- Object
- Rake::Delphi::Git
- Defined in:
- lib/rake/common/git.rb
Class Method Summary collapse
Class Method Details
.version ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rake/common/git.rb', line 10 def self.version null = Rake.cygwin? ? '/dev/null' : 'nul' r = `git rev-parse 1>#{null} 2>&1 && git describe --abbrev=1 2>#{null}` # trim r.chomp! unless r.to_s.empty? # add ".0" for exact version (like v3.0.43) # example: v3.0.43-5-g3952dc # take text before '-g' r << '.0' r = r.split('-g')[0] # remove any non-digits in the beginning # remove any alpha-characters r.gsub!(/^\D+|[a-zA-Z]+/, '') # replace any non-digits with dots r.gsub!(/\D/, '.') end end |