changeset 12:6e272c520bc6

Read version information from .hg_archival.txt when available.
author Mikhail Kryshen <mikhail@kryshen.net>
date Tue, 17 Jul 2012 08:16:34 +0400
parents 27996848b621
children 21bc7e1d1429
files Rakefile
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Rakefile	Tue Jul 17 07:18:12 2012 +0400
+++ b/Rakefile	Tue Jul 17 08:16:34 2012 +0400
@@ -13,7 +13,13 @@
 task :compile => SRC do
   Mirah::compile '--jvm', '1.6', '-d', 'build', *SRC
 
-  version = `hg log -r tip --template "{latesttag}.{latesttagdistance}"`
+  begin
+    hga = Hash[*File.read('.hg_archival.txt').split(/: |\n+/)]
+    version = "#{hga['latesttag']}.#{hga['latesttagdistance']}"
+  rescue Errno::ENOENT
+    version = `hg log -r tip --template "{latesttag}.{latesttagdistance}"`
+  end
+
   File.open('build/net/kryshen/charamega/version.properties', 'w') do |f|
     f.write "version = #{version}\n"
   end