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

diff --git a/Changes b/Changes
index 8003beed1dd19d313b09190071a536c4647ffc83..c6d7e678050cb7bf54cad91349ded731584e6133 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.
+1. Alter show/version to show the current git branch we are running on.
 24Apr20=======================================================================
 1. Add CTY-3008 prefixes
 22Apr20=======================================================================
index 7107570d969c0e5108b57bb48508b89c81285351..0b0f0cfb66df9645b7675af023173a2810f48c22 100644 (file)
@@ -6,10 +6,26 @@
 #
 #
 
+my ($self, $line) = @_;
 my @out;
-my ($year) = (gmtime($main::systime))[5];
-$year += 1900;
-push @out, "DX Spider Cluster version $main::version (build $main::subversion.$main::build git: $main::gitversion) on \u$^O";
-push @out, "Copyright (c) 1998-$year Dirk Koopman G1TLH";
+my @in = map {uc} split /\s+/, $line;
+
+if ($self->priv > 5 && @in) {
+#              $DB::single=1;
+
+       my $q = $in[0] eq 'ALL' ? '.*' : join('|', @in);
+       my @n = sort {$a->call cmp $b->call} grep {$_->call =~ /^(?:$q)/} Route::Node::get_all();
+       push @out, " Node      Version  Build  PC9X  via PC92";
+       foreach my $n (@n) {
+               push @out, sprintf " %-10s  %5d  %5s   %3s       %3s", $n->call, $n->version, $n->build, yesno($n->do_pc9x), yesno($n->via_pc92);
+       }
+       push @out, ' ' . scalar @n . " Nodes found";
+} else {
+       my ($year) = (gmtime($main::systime))[5];
+       $year += 1900;
+       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";
+}
+
 
 return (1, @out);
index fc116f8e7ed3c191b7c538c7b8f87c176351d4ec..d829fc37a30f63bc06c083d65b1ed254a31ea154 100644 (file)
@@ -130,7 +130,7 @@ sub pc17
 sub pc18
 {
        my $flags = shift;
-       return "PC18^DXSpider Version: $main::version Build: $main::subversion.$main::build Git: $main::gitversion$flags^$DXProt::myprot_version^";
+       return "PC18^DXSpider Version: $main::version Build: $main::subversion.$main::build Git: $main::gitbranch/$main::gitversion$flags^$DXProt::myprot_version^";
 }
 
 #
index b9031719718fc291e1ef18343a65b4639af872a8..9c47042b396ac0e13d12a6f3d02b82a7e093bd18 100755 (executable)
@@ -128,7 +128,6 @@ use Data::Dumper;
 use IO::File;
 use Fcntl ':flock';
 use POSIX ":sys_wait_h";
-use Version;
 
 use Local;
 
@@ -155,6 +154,8 @@ $maxconnect_node = 0;                       # Ditto but for nodes. In either case if a new incoming
                                                                # takes the no of references in the routing table above these numbers
                                                                # then the connection is refused. This only affects INCOMING connections.
 
+use vars qw($version $subversion $build $gitversion $gitbranch);
+
 # send a message to call on conn and disconnect
 sub already_conn
 {
@@ -318,7 +319,7 @@ sub cease
                $l->close_server;
        }
 
-       LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) ended");
+       LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitbranch/$gitversion) ended");
        dbgclose();
        Logclose();
 
@@ -403,6 +404,8 @@ if (DXSql::init($dsn)) {
                import Git;
                
                # determine the real version number
+               $gitbranch = 'none';
+        $gitversion = 'none';
                my $repo = Git->repository(Directory => "$root/.git");
                if ($repo) {
                        my $desc = $repo->command_oneline(['describe'], STDERR => 0);
@@ -414,6 +417,15 @@ if (DXSql::init($dsn)) {
                                $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;
 }
@@ -424,7 +436,7 @@ DXXml::init();
 # banner
 my ($year) = (gmtime)[5];
 $year += 1900;
-LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) started");
+LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitbranch/$gitversion) started");
 dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH");
 
 # load Prefixes