3 CONSTANT
= "Rainbows::Const::RAINBOWS_VERSION"
4 RVF
= "lib/rainbows/version.rb"
5 GVF
= "GIT-VERSION-FILE"
8 # First see if there is a version file (included in release tarballs),
9 # then try git-describe, then default.
10 if File
.exist
?(".git")
11 describe
= `git describe --abbrev=4 HEAD 2>/dev/null`.strip
15 system(*%w(git update-index
-q
--refresh
))
16 unless `git diff-index --name-only HEAD --`.chomp
.empty
?
23 vn
= vn
.sub
!(/\Av/, "")
25 # generate the Ruby constant
26 new_ruby_version
= "#{CONSTANT} = '#{vn}'\n"
27 cur_ruby_version
= File
.read(RVF
) rescue nil
28 if new_ruby_version
!= cur_ruby_version
29 File
.open(RVF
, "w") { |fp
| fp
.write(new_ruby_version
) }
32 # generate the makefile snippet
33 new_make_version
= "GIT_VERSION = #{vn}\n"
34 cur_make_version
= File
.read(GVF
) rescue nil
35 if new_make_version
!= cur_make_version
36 File
.open(GVF
, "w") { |fp
| fp
.write(new_make_version
) }
39 puts vn
if $0 == __FILE__