mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 20:09:43 +01:00
Setting PBot.pm $VERSION from build script instead
This commit is contained in:
parent
8c03a7b18b
commit
4e4574d2b6
11
PBot/PBot.pm
11
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);
|
||||
|
30
build/update-version.pl
Executable file
30
build/update-version.pl
Executable file
@ -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;
|
Loading…
Reference in New Issue
Block a user