2014-11-02 15:30:49 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# $Id: commandref_join.pl 5361 2014-03-29 06:24:20Z rudolfkoenig $
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
sub err($$);
|
|
|
|
|
|
|
|
my $svnlook='/usr/bin/svnlook';
|
|
|
|
my $repos=$ARGV[0];
|
|
|
|
my $txn=$ARGV[1];
|
|
|
|
my $arg="-t $txn";
|
|
|
|
#my $arg="-r $txn"; # local testing
|
|
|
|
my @lang = ("EN", "DE");
|
|
|
|
my $exitCode = 0;
|
2015-12-29 18:00:04 +00:00
|
|
|
use constant TAGS => qw{ul li code b i u table tr td};
|
2016-01-02 15:12:27 +00:00
|
|
|
use constant LINECHECK => qw{CHANGED};
|
2014-11-02 15:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
my $log = `$svnlook log $arg $repos`;
|
|
|
|
if($log !~ m/^.*:.*$/s) {
|
2014-11-02 15:38:42 +00:00
|
|
|
print STDERR << 'EOF';
|
2014-11-02 15:30:49 +00:00
|
|
|
A FHEM SVN comment must have the following format
|
|
|
|
module: text-describing-the-change
|
|
|
|
or
|
|
|
|
module: text-describing-the-change (Forum #<forum.fhem.de threadnumber>)
|
|
|
|
EOF
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $fList = `$svnlook changed $arg $repos`;
|
|
|
|
foreach my $row (split("\n", $fList)) {
|
|
|
|
chomp($row);
|
|
|
|
my ($type, $fName) = split(" ", $row);
|
2014-11-23 08:55:02 +00:00
|
|
|
next if($type eq "D");
|
2016-01-02 15:12:27 +00:00
|
|
|
next if(!$fName || !grep($fName, LINECHECK) || $fName !~ m+FHEM/\d\d_(.*).pm$+);
|
2014-11-02 15:30:49 +00:00
|
|
|
my $modName = $1;
|
|
|
|
|
2016-01-02 15:12:27 +00:00
|
|
|
# check for 80 chars per line conformity
|
|
|
|
if(grep($fName, LINECHECK)) {
|
|
|
|
my $cCount = 0;
|
|
|
|
open(FILE, "$svnlook $arg cat $repos $fName|") ||
|
|
|
|
die("Cant svnlook cat $fName:$!\n");
|
|
|
|
while(my $l = <FILE>) {
|
|
|
|
chomp $l;
|
|
|
|
$cCount = length($l) if(length($l) > $cCount);
|
|
|
|
}
|
|
|
|
close(FILE);
|
|
|
|
err $fName, "$fName: file has over 80 chars/line" if($cCount > 80);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2014-11-02 15:30:49 +00:00
|
|
|
foreach my $lang (@lang) {
|
|
|
|
my $suffix = ($lang eq "EN" ? "" : "_$lang");
|
|
|
|
my $tag;
|
|
|
|
my %tagcount= ();
|
|
|
|
my %llwct = (); # Last line with closed tag
|
|
|
|
open(MOD, "$svnlook $arg cat $repos $fName|") ||
|
|
|
|
die("Cant svnlook cat $fName:$!\n");
|
|
|
|
my $skip = 1;
|
|
|
|
my $line = 0;
|
|
|
|
my $docCount = 0;
|
|
|
|
my $hasLink = 0;
|
|
|
|
while(my $l = <MOD>) {
|
|
|
|
$line++;
|
|
|
|
|
|
|
|
err $fName, "DOS line encoding is not supported."
|
|
|
|
if($l =~ m/^=begin html$suffix.*\r/);
|
|
|
|
|
|
|
|
if($l =~ m/^=begin html$suffix$/) {
|
|
|
|
$l = <MOD>; # skip one line, to be able to repeat join+split
|
|
|
|
err($fName, "$lang: nonempty line after =begin html.")
|
|
|
|
if($l =~ m/^...*$/);
|
|
|
|
$skip = 0; $line++;
|
|
|
|
|
|
|
|
} elsif($l =~ m/^=end html$suffix$/) {
|
|
|
|
$skip = 1;
|
|
|
|
|
|
|
|
} elsif(!$skip) {
|
|
|
|
$docCount++;
|
|
|
|
$hasLink = ($l =~ m/<a name="$modName"/) if(!$hasLink);
|
|
|
|
foreach $tag (TAGS) {
|
|
|
|
my $ot = ($tagcount{$tag} ? $tagcount{$tag} : 0);
|
|
|
|
$tagcount{$tag} +=()= ($l =~ /<$tag>/gi);
|
|
|
|
$tagcount{$tag} -=()= ($l =~ /<\/$tag>/gi);
|
|
|
|
$llwct{$tag} = $line if(!$llwct{$tag} || ($ot && !$tagcount{$tag}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(MOD);
|
|
|
|
|
|
|
|
err $fName, "$lang: No document text found"
|
|
|
|
if(!$suffix && !$docCount);
|
|
|
|
err $fName, "$lang: No <a name=\"$modName\"> link"
|
|
|
|
if(!$suffix && $docCount && !$hasLink);
|
|
|
|
foreach $tag (TAGS) {
|
|
|
|
err $fName, "$lang: Unbalanced $tag ($tagcount{$tag}, last line ok: $llwct{$tag})"
|
|
|
|
if($tagcount{$tag});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit($exitCode);
|
|
|
|
|
|
|
|
sub
|
|
|
|
err($$)
|
|
|
|
{
|
|
|
|
my ($fName, $txt) = @_;
|
2014-11-02 15:38:42 +00:00
|
|
|
print STDERR "*** $fName: $txt\n";
|
2014-11-02 15:30:49 +00:00
|
|
|
$exitCode = 1;
|
|
|
|
}
|