make sure the version installed is updated on a testup with changed files
[bse.git] / site / util / check_versions.pl
CommitLineData
cb7fd78d
TC
1#!perl -w
2use strict;
3
4my %vers;
5
0f35f2b7 6my @check = `git status -s`;
cb7fd78d
TC
7chomp @check;
8@check = sort grep /cgi-bin\/.*\.pm$/, @check;
ed1ff43e 9@check = grep !m(BSE/(Modules|Version)\.pm), @check;
cb7fd78d
TC
10my @errors;
11for my $check (@check) {
12 $check =~ /^D/ and next;
13 $check =~ s/^(\S)\S*\s+//;
14 my $type = $1;
15 -e $check or die "Cannot find file $check\n";
16
17 my $ver = file_vers($check);
18
19 unless ($type eq "A") {
0f35f2b7
TC
20 my $committed = `git show HEAD:$check`;
21 my $old_ver = content_vers($committed);
cb7fd78d
TC
22
23 if (defined $old_ver) {
24 $old_ver eq $ver
25 and push @errors, "Version not updated in $check\n";
26 }
27 }
28}
29
30@errors and die @errors;
31
32sub file_vers {
33 my ($filename) = @_;
34
35 open my $file, "<", $filename
36 or die "Cannot open $filename; $!\n";
37 my $content = do { local $/; <$file> };
38 close $file;
39
40 my $vers = content_vers($content)
41 or die "No version found in $filename\n";
42
43 return $vers;
44}
45
46sub content_vers {
47 my ($lines) = @_;
48
49 $lines =~ /^our \$VERSION = "([0-9.]+)";/m
50 or return;
51
52 return $1;
53}