diff options
author | Saku Ytti <saku@ytti.fi> | 2018-04-26 00:26:27 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2018-04-26 00:26:27 +0300 |
commit | 377faa395d79c485ce9dfea6a0483067684d8ada (patch) | |
tree | f5d3246e4304d26ace195444ba2e6f02a473138f /lib/oxidized | |
parent | f12c9c69fff97007b685fb1049fd82e95c451b1c (diff) |
safe guard version for environment without git
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/version.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/oxidized/version.rb b/lib/oxidized/version.rb index de99d5f..a5422fd 100644 --- a/lib/oxidized/version.rb +++ b/lib/oxidized/version.rb @@ -2,13 +2,17 @@ module Oxidized VERSION = '0.21.0' VERSION_FULL = '0.21.0-180-g9691008' def self.version_set - Oxidized.send(:remove_const, :VERSION_FULL) - const_set(:VERSION_FULL, %x(git describe --tags).chop) - Oxidized.send(:remove_const, :VERSION) - const_set(:VERSION, %x(git describe --tags --abbrev=0).chop) - file = File.readlines(__FILE__) - file[1] = " VERSION = '%s'\n" % VERSION - file[2] = " VERSION_FULL = '%s'\n" % VERSION_FULL - File.write(__FILE__, file.join) + version_full = %x(git describe --tags).chop rescue "" + version = %x(git describe --tags --abbrev=0).chop rescue "" + if [version, version_full].none? &:empty? + Oxidized.send(:remove_const, :VERSION) + Oxidized.send(:remove_const, :VERSION_FULL) + const_set(:VERSION, version) + const_set(:VERSION_FULL, version_full) + file = File.readlines(__FILE__) + file[1] = " VERSION = '%s'\n" % VERSION + file[2] = " VERSION_FULL = '%s'\n" % VERSION_FULL + File.write(__FILE__, file.join) + end end end |