Meta.pm: be strict when using VCS data

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18888 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-03-13 11:09:23 +00:00
parent 4e017a6a1a
commit 3c18cf9b8f

View File

@ -343,6 +343,8 @@ our %supportForumCategories = (
); );
our %moduleMaintainers; our %moduleMaintainers;
our %packageMaintainers;
our %fileMaintainers;
our $coreUpdate; our $coreUpdate;
our %corePackageUpdates; our %corePackageUpdates;
@ -1017,7 +1019,14 @@ m/(^#\s+(?:\d{1,2}\.\d{1,2}\.(?:\d{2}|\d{4})\s+)?[^v\d]*(v?(?:\d{1,3}\.\d{1,3}(?
# use VCS info 'as is', but only when: # use VCS info 'as is', but only when:
# - file name matches # - file name matches
# - file has maintainer in MAINTAINER.txt # - file has maintainer in MAINTAINER.txt
if ( @vcs && $vcs[1] eq $modMeta->{x_file}[2] ) { # - or it is our own package of course
if ( @vcs
&& $vcs[1] eq $modMeta->{x_file}[2] )
{
if ( defined( $moduleMaintainers{ $modMeta->{x_file}[4] } )
|| defined( $packageMaintainers{ $modMeta->{x_file}[4] } )
|| $modMeta->{x_file}[4] eq 'Meta' )
{
push @vcs, push @vcs,
fhemTimeGm( fhemTimeGm(
$vcs[14], $vcs[13], $vcs[12], $vcs[10], $vcs[14], $vcs[13], $vcs[12], $vcs[10],
@ -1026,6 +1035,14 @@ m/(^#\s+(?:\d{1,2}\.\d{1,2}\.(?:\d{2}|\d{4})\s+)?[^v\d]*(v?(?:\d{1,3}\.\d{1,3}(?
); );
$modMeta->{x_vcs} = \@vcs; $modMeta->{x_vcs} = \@vcs;
} }
else {
Log 3,
__PACKAGE__
. "::__GetMetadata WARNING: Unregistered core module or package:\n "
. $modMeta->{x_file}[0]
. ' has defined VCS data but is not registered in MAINTAINER.txt';
}
}
# author has put version into JSON # author has put version into JSON
if ( defined( $modMeta->{version} ) ) { if ( defined( $modMeta->{version} ) ) {
@ -1253,7 +1270,10 @@ sub __GetMaintainerdata {
if ( open( $fh, '<' . $attr{global}{modpath} . '/MAINTAINER.txt' ) ) { if ( open( $fh, '<' . $attr{global}{modpath} . '/MAINTAINER.txt' ) ) {
my $skip = 1; my $skip = 1;
while ( my $l = <$fh> ) { while ( my $l = <$fh> ) {
$skip = 0 if ( $l =~ m/^===+$/ ); if ( $l =~ m/^===+$/ ) {
$skip = 0;
next;
}
next if ($skip); next if ($skip);
my @line = map { my @line = map {
@ -1264,10 +1284,20 @@ sub __GetMaintainerdata {
if ( $line[0] =~ m/^((.+\/)?((?:(\d+)_)?(.+?)(?:\.(.+))?))$/ ) { if ( $line[0] =~ m/^((.+\/)?((?:(\d+)_)?(.+?)(?:\.(.+))?))$/ ) {
# Ignore all files that are not a main module for now
next unless ($4);
my @maintainer; my @maintainer;
# This is a FHEM module file,
# either in ./ or ./FHEM/. For files in ./,
# file extension must be provided.
# Files in ./FHEM/ use file order number to identify.
if (
(
( !$2 || $2 eq '' || $2 eq './' )
&& ( $6 && ( $6 eq 'pl' || $6 eq 'pm' ) )
)
|| ( $4 && $2 eq 'FHEM/' )
)
{
$maintainer[0][0] = $1; # complete match $maintainer[0][0] = $1; # complete match
$maintainer[0][1] = $2; # relative file path $maintainer[0][1] = $2; # relative file path
$maintainer[0][2] = $3; # file name $maintainer[0][2] = $3; # file name
@ -1290,10 +1320,46 @@ sub __GetMaintainerdata {
. join( ' ', @line ); . join( ' ', @line );
} }
else { else {
$moduleMaintainers{ $maintainer[0][4] } = \@maintainer; $moduleMaintainers{ $maintainer[0][4] } = \@maintainer;
} }
} }
# This is a FHEM Perl package under ./FHEM/,
# used by FHEM modules.
# Packages must provide file extension here.
elsif ( $2 && $2 eq 'FHEM/' && $6 eq 'pm' ) {
$maintainer[0][0] = $1; # complete match
$maintainer[0][1] = $2; # relative file path
$maintainer[0][2] = $3; # file name
$maintainer[0][3] = $4; # order number,
# empty here but we want the same structure
$maintainer[0][4] = $5; # FHEM package name
$maintainer[0][5] = $6; # file extension
$maintainer[1] = $line[1]; # Maintainer alias name
$maintainer[2] = $line[2]; # Forum support section
if ( defined( $packageMaintainers{ $maintainer[0][4] } ) ) {
Log 1,
__PACKAGE__
. "::__GetMaintainerdata ERROR: Duplicate entry:\n"
. ' 1st: '
. $packageMaintainers{ $maintainer[0][4] }[0][0] . ' '
. $packageMaintainers{ $maintainer[0][4] }[1] . ' '
. $packageMaintainers{ $maintainer[0][4] }[2]
. "\n 2nd: "
. join( ' ', @line );
}
else {
$packageMaintainers{ $maintainer[0][4] } = \@maintainer;
}
}
# this is a FHEM file
# under any path
else {
# our %fileMaintainers;
}
}
} }
close($fh); close($fh);
@ -1593,7 +1659,7 @@ sub __SetXVersion {
"metadata", "metadata",
"meta" "meta"
], ],
"version": "v0.1.6", "version": "v0.1.7",
"release_status": "testing", "release_status": "testing",
"author": [ "author": [
"Julian Pawlowski <julian.pawlowski@gmail.com>" "Julian Pawlowski <julian.pawlowski@gmail.com>"