From 4382169e60b212ef0541bcf83cc9886c6fa34a8b Mon Sep 17 00:00:00 2001 From: Doug Freed Date: Thu, 14 Jul 2016 06:55:00 -0700 Subject: Add a version command. *NOTE*: Reflects the state of git only at the time the bot is started. Version is not updated in any way at runtime. First field is the newest commit that exists both locally and on GitLab. Second field is the output of `git describe --all --long --dirty`. Third field is the latest commit locally. --- lib/ASM/Commander.pm | 7 +++++++ meta.pl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm index e91dc44..f37aaf0 100644 --- a/lib/ASM/Commander.pm +++ b/lib/ASM/Commander.pm @@ -149,6 +149,8 @@ my $cmdtbl = { '^;explain (?\S+)\s+(?\S+)\s*$' => { 'flag' => 's', 'cmd' => \&cmd_explain }, + '^;version$' => { + 'cmd' => \&cmd_version }, }; sub new { @@ -1101,4 +1103,9 @@ sub cmd_explain { # all hosts associated with two given nicks $conn->privmsg($event->replyto, $header . ASM::Util->commaAndify(sort @$result)); } +sub cmd_version { + my ($conn, $event) = @_; + $conn->privmsg($event->replyto, $::version); +} + # vim: ts=8:sts=8:sw=8:noexpandtab diff --git a/meta.pl b/meta.pl index 1730942..7f03197 100755 --- a/meta.pl +++ b/meta.pl @@ -47,6 +47,7 @@ $::pacealerts = 1; $::settingschanged = 0; %::wordlist = (); %::httpRequests = (); +$::version = ''; ## debug variables. 0 to turn off debugging, else set it to a Term::ANSIColor constant. %::debugx = ( @@ -97,6 +98,11 @@ alarm 300; sub init { my ( $conn, $host ); + $::version .= `git merge-base remotes/origin/master HEAD`; chomp $::version; + $::version .= ' '; + $::version .= `git describe --long --all --dirty`; chomp $::version; + $::version .= ' '; + $::version .= `git rev-parse HEAD`; chomp $::version; my $irc = new Net::IRC; GetOptions( 'debug|d!' => \$::debug, 'pass|p=s' => \$::pass, -- cgit v1.2.3