show git branch in show/version
authorDirk Koopman <djk@tobit.co.uk>
Wed, 20 May 2020 15:10:02 +0000 (16:10 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Wed, 20 May 2020 15:10:02 +0000 (16:10 +0100)
Changes
cmd/show/version.pl
perl/cluster.pl

diff --git a/Changes b/Changes
index 103343ed1568c832fa6e87c664e6e989d58d518f..1af58d83ca8c6471bf393d56f7007234b387eb2b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,7 @@
    mojo branch. Running this program just *BEFORE* doing your next update of
    the mojo branch *should* ensure a seemless transition to the Storable &
    DB_File free version of the users file. 
+2. Show git branch in show/version.
 17May20=======================================================================
 1. Backport DXSubprocess to change serialisations.
    Currently the internals of Mojo::IOLoop::Subprocess defaults to
index 31acc5caddcd10a5d425003d4a9857d316cde9a0..0b0f0cfb66df9645b7675af023173a2810f48c22 100644 (file)
@@ -23,7 +23,7 @@ if ($self->priv > 5 && @in) {
 } else {
        my ($year) = (gmtime($main::systime))[5];
        $year += 1900;
-       push @out, "DX Spider Cluster version $main::version (build $main::build git: $main::gitversion) on \u$^O";
+       push @out, "DX Spider Cluster version $main::version (build $main::build git: $main::gitbranch/$main::gitversion) on \u$^O";
        push @out, "Copyright (c) 1998-$year Dirk Koopman G1TLH";
 }
 
index 6c0ff3d691490d4db977e2d03108ec6f31ca1071..5baf02973ac49a4c385c95d7fc1dcf8121febd09 100755 (executable)
@@ -153,9 +153,10 @@ use Data::Dumper;
 use IO::File;
 use Fcntl ':flock';
 use POSIX ":sys_wait_h";
-use Version;
 use Web;
 
+use vars qw($version $build $gitversion $gitbranch);
+
 use Local;
 
 
@@ -380,7 +381,6 @@ sub cease
                $SIG{'INT'} = 'IGNORE';
        }
 
-       DXUser::sync;
 
        if (defined &Local::finish) {
                eval {
@@ -409,7 +409,7 @@ sub cease
                $l->close_server;
        }
 
-       LogDbg('cluster', "DXSpider V$version, build $build (git: $gitversion) ended");
+       LogDbg('cluster', "DXSpider V$version, build $build (git: $gitbranch/$gitversion) ended");
        dbg("bye bye everyone - bye bye");
        dbgclose();
        Logclose();
@@ -493,6 +493,8 @@ sub setup_start
                        import Encode;
                        $can_encode = 1;
                }
+               $gitbranch = 'none';
+               $gitversion = 'none';
                eval { require Git; };
                unless ($@) {
                        import Git;
@@ -510,6 +512,14 @@ sub setup_start
                                        $build = $b || 0;
                                        $gitversion = "$g\[r]";
                                }
+                               my @branch = $repo->command([qw{branch}], STDERR=>0);
+                               for (@branch) {
+                                       my ($star, $b) = split /\s+/;
+                                       if ($star eq '*') {
+                                               $gitbranch = $b;
+                                               last;
+                                       }
+                               }
                        }
                }
                $SIG{__DIE__} = $w;
@@ -521,7 +531,7 @@ sub setup_start
        # banner
        my ($year) = (gmtime)[5];
        $year += 1900;
-       LogDbg('cluster', "DXSpider V$version, build $build (git: $gitversion) started");
+       LogDbg('cluster', "DXSpider V$version, build $build (git: $gitbranch/$gitversion) started");
        dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH");
 
        # load Prefixes
@@ -536,7 +546,7 @@ sub setup_start
 
        # initialise User file system
        dbg("loading user file system ...");
-       DXUser::init(1);
+       DXUser::init(4);                        # version 4 == json format
 
        # look for the sysop and the alias user and complain if they aren't there
        {