From: Dirk Koopman Date: Tue, 14 Oct 2014 16:09:42 +0000 (+0100) Subject: use real git version if git is available X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=c664bf735ebbf814c651b6d9d94fbd5abb8cd15c;p=spider.git use real git version if git is available --- diff --git a/perl/Version.pm b/perl/Version.pm index e4c207ff..e43ab22c 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,7 +11,7 @@ use vars qw($version $subversion $build $gitversion); $version = '1.55'; $subversion = '0'; -$build = '160'; -$gitversion = '56478c6'; +$build = '161'; +$gitversion = '7a39506[i]'; 1; diff --git a/perl/cluster.pl b/perl/cluster.pl index 5b65717e..81e23cf8 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -370,7 +370,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__}; @@ -380,6 +380,23 @@ 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; + $subversion = $s || 0; + $build = $b || 0; + $gitversion = "$g\[r]"; + } + } + } $SIG{__DIE__} = $w; } diff --git a/perl/issue.pl b/perl/issue.pl index 065c9abd..802c12e6 100755 --- a/perl/issue.pl +++ b/perl/issue.pl @@ -38,7 +38,7 @@ use vars qw(\$version \$subversion \$build \$gitversion); \$version = '$v'; \$subversion = '$s'; \$build = '$b'; -\$gitversion = '$g'; +\$gitversion = '$g\[i]'; 1; );