2 # Copyright (C) 2013-2019 all contributors <yahns-public@yhbt.net>
3 # License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
4 # frozen_string_literal: true
5 CONSTANT
= "Yahns::VERSION"
6 RVF
= "lib/yahns/version.rb"
7 GVF
= "GIT-VERSION-FILE"
11 # First see if there is a version file (included in release tarballs),
12 # then try git-describe, then default.
13 if File
.exist
?(".git")
14 describe
= `git describe --abbrev=4 HEAD 2>/dev/null`.strip
18 system(*%w(git update-index
-q
--refresh
))
19 unless `git diff-index --name-only HEAD --`.chomp
.empty
?
26 vn
= vn
.sub
!(/\Av/, "")
27 new_ruby_version
= "#{CONSTANT} = '#{vn}'.freeze # :nodoc:\n"
28 cur_ruby_version
= File
.read(RVF
) rescue nil
29 if new_ruby_version
!= cur_ruby_version
30 File
.open(RVF
, "w") { |fp
| fp
.write(new_ruby_version
) }
34 # generate the makefile snippet
35 new_make_version
= "VERSION = #{vn}\n"
36 cur_make_version
= File
.read(GVF
) rescue nil
37 if new_make_version
!= cur_make_version
38 File
.open(GVF
, "w") { |fp
| fp
.write(new_make_version
) }
42 puts vn
if $0 == __FILE__