From 3e09ac0c10c95bb24a08af62393b4f761e2743d0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Aug 2013 09:54:45 +0000 Subject: initial commit --- GIT-VERSION-GEN | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 GIT-VERSION-GEN (limited to 'GIT-VERSION-GEN') diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN new file mode 100755 index 0000000..f690dcd --- /dev/null +++ b/GIT-VERSION-GEN @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +# Copyright (C) 2013, Eric Wong +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +CONSTANT = "DTAS::VERSION" +RVF = "lib/dtas/version.rb" +DEF_VER = "v0.0.0" +vn = DEF_VER + +# First see if there is a version file (included in release tarballs), +# then try git-describe, then default. +if File.exist?(".git") + describe = `git describe --abbrev=4 HEAD 2>/dev/null`.strip + case describe + when /\Av[0-9]*/ + vn = describe + system(*%w(git update-index -q --refresh)) + unless `git diff-index --name-only HEAD --`.chomp.empty? + vn << "-dirty" + end + vn.tr!('-', '.') + end +end + +vn = vn.sub!(/\Av/, "") +new_ruby_version = "#{CONSTANT} = '#{vn}'\n" +cur_ruby_version = File.read(RVF) rescue nil +if new_ruby_version != cur_ruby_version + File.open(RVF, "w") { |fp| fp.write(new_ruby_version) } +end +puts vn if $0 == __FILE__ -- cgit v1.2.3-24-ge0c7