diff --git a/PBot/PBot.pm b/PBot/PBot.pm index 3f2faca9..5d713cff 100644 --- a/PBot/PBot.pm +++ b/PBot/PBot.pm @@ -10,10 +10,15 @@ package PBot::PBot; use strict; use warnings; -# If you're creating a fork/branch of this code, please rename this file to include the branch name, e.g. PBot-fork.pm -# so that the !version command appropriately reflects this. +# These are set automatically by the build/commit script +use constant { + BUILD_NAME => "PBot", + BUILD_REVISION => 140, + BUILD_DATE => "2010-06-04", +}; + use vars qw($VERSION); -$VERSION = sprintf "%s revision %d %s", q$Id$ =~ /: ([^.]+)\.pm (\d+) ([^ ]+)/g; +$VERSION = BUILD_NAME . " revision " . BUILD_REVISION . " " . BUILD_DATE; # unbuffer stdout STDOUT->autoflush(1); diff --git a/build/update-version.pl b/build/update-version.pl new file mode 100755 index 00000000..127e116f --- /dev/null +++ b/build/update-version.pl @@ -0,0 +1,30 @@ +#!perl + +use warnings; +use strict; + +use POSIX qw(strftime); + +my $svn_info = `svn info -r head`; +my ($rev) = $svn_info =~ /Last Changed Rev: (\d+)/; +my $date = strftime "%Y-%m-%d", localtime; + +$rev++; + +print "New version: $rev $date\n"; + +open my $in, '<', "PBot/PBot.pm" or die "Couldn't open PBot.pm for reading: $!"; +my @lines = <$in>; +close $in; + +open my $out, '>', "PBot/PBot.pm" or die "Couldn't open PBot.pm for writing: $!"; + +foreach my $text (@lines) { + $text =~ s/BUILD_NAME\s+=> ".*",/BUILD_NAME => "PBot",/; + $text =~ s/BUILD_REVISION\s+=> \d+,/BUILD_REVISION => $rev,/; + $text =~ s/BUILD_DATE\s+=> ".*",/BUILD_DATE => "$date",/; + + print $out $text; +} + +close $out;