bin/sisu when run from dir tree, check git describe version info
authorRalph Amissah <ralph@amissah.com>
Sun, 12 Apr 2015 19:56:19 +0000 (15:56 -0400)
committerRalph Amissah <ralph@amissah.com>
Mon, 13 Apr 2015 20:39:36 +0000 (16:39 -0400)
bin/sisu

index dc399737982a87e0a164072485f68b78bded4c2b..9bb41736bb974551efaecc6d881fa7fb22ae41b7 100644 (file)
--- a/bin/sisu
+++ b/bin/sisu
@@ -163,6 +163,25 @@ class Orient
     else nil
     end
   end
+  def git_version
+    if sisu_run_from? == :full_path_to_sisu_bin_in_sisu_dir_tree \
+    && FileTest.file?('/usr/bin/git') \
+    && FileTest.directory?(processing.sisu_runtime_path.gsub(/\/bin\/sisu\S*/,'/.git'))
+      bin_base=processing.sisu_runtime_path.gsub(/\/bin\/sisu\S*/,'')
+      pwd=Dir.pwd
+      Dir.chdir(bin_base)
+      x=`git describe --long --tags 2>&1`.strip.
+        gsub(/^[a-z_-]*([0-9.]+)/,'\1').
+        gsub(/([^-]*-g)/,'r\1').
+        gsub(/-/,'.')
+      x=(x=~/^[0-9]+\.[0-9]+\.[0-9]+\.r[0-9]+\.g[0-9a-f]{7}/) \
+      ? x
+      : nil
+      Dir.chdir(pwd)
+      x
+    else nil
+    end
+  end
   def sisu_path_base
     case paths_set
     when :set_path_system
@@ -238,6 +257,9 @@ class Orient
     def language_list_regex?
       language_list.regex
     end
+    def git_version_info?
+      git_version
+    end
     def runtime?
       {
         call_path:    called_from?,