test/test_extras_exec_cgi: drop Rack::ContentLength
[yahns.git] / GIT-VERSION-GEN
blob31e49e79519373bb281f3d40bc9766130bdaa9d5
1 #!/usr/bin/env ruby
2 # Copyright (C) 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"
8 DEF_VER = "v1.18.0"
9 vn = DEF_VER.dup
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
15 case describe
16 when /\Av[0-9]*/
17 vn = describe
18 system(*%w(git update-index -q --refresh))
19 unless `git diff-index --name-only HEAD --`.chomp.empty?
20 vn << "-dirty"
21 end
22 vn.tr!('-', '.')
23 end
24 end
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) }
31 end
32 File.chmod(0644, RVF)
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) }
39 end
40 File.chmod(0644, GVF)
42 puts vn if $0 == __FILE__