use real git version if git is available
[spider.git] / perl / cluster.pl
index 70b81f71d031903ea9e2862ef998d6a2f10d5c5e..1e10eb518aae676ddbe0d8b85df3825951e52455 100755 (executable)
@@ -438,7 +438,7 @@ if (DXSql::init($dsn)) {
        $dbh = $dbh->connect($dsn, $dbuser, $dbpass) if $dbh;
 }
 
-# try to load Encode
+# try to load Encode and Git
 {
        local $^W = 0;
        my $w = $SIG{__DIE__};
@@ -448,6 +448,22 @@ if (DXSql::init($dsn)) {
                import Encode;
                $can_encode = 1;
        }
+       eval { require Git; };
+       unless ($@) {
+               import Git;
+               
+               # determine the real version number
+               my $repo = Git->repository(Directory => "$root/.git");
+               if ($repo) {
+                       my $desc = $repo->command_oneline(['describe', '--long'], STDERR => 0);
+                       if ($desc) {
+                               my ($v, $s, $b, $g) = $desc =~ /^([\d.]+)(?:\.(\d+))?-(\d+)-g([0-9a-f]+)/;
+                               $version = $v;
+                               $build = $b || 0;
+                               $gitversion = "$g\[r]";
+                       }
+               }
+       }
        $SIG{__DIE__} = $w;
 }