mod-Weather/hooks/pre-commit
Marko Oldenburg 12595b3674 ```
Refactor pre-commit hook file list and output formatting

Updated the list of files in the pre-commit hook to remove
references to 'lib/FHEM/APIs/Weather/DarkSkyAPI.pm' and adjusted
the output formatting for better readability. The order of the
files in the @filenames array has been restructured for clarity.
These changes were necessary to ensure our code base focuses on
the more relevant weather API files.

No breaking changes introduced; the pre-commit hook continues to
function as intended.
```
2025-02-05 07:07:52 +01:00

44 lines
1.0 KiB
Perl
Executable File

#!/usr/bin/perl -w
use File::Basename;
use POSIX qw(strftime);
use strict;
my @filenames = (
'FHEM/59_Weather.pm',
'lib/FHEM/Core/Weather.pm',
'lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm',
'lib/FHEM/APIs/Weather/wundergroundAPI.pm',
);
my $controlsfile = 'controls_Weather.txt';
open( FH, ">$controlsfile" ) || return ("Can't open $controlsfile: $!");
for my $filename (@filenames) {
my @statOutput = stat($filename);
if ( scalar @statOutput != 13 ) {
printf 'error: stat has unexpected return value for '
. $filename . "\n";
next;
}
my $mtime = $statOutput[9];
my $date = POSIX::strftime( "%Y-%m-%d", localtime($mtime) );
my $time = POSIX::strftime( "%H:%M:%S", localtime($mtime) );
my $filetime = $date . "_" . $time;
my $filesize = $statOutput[7];
printf FH 'UPD ' . $filetime . ' ' . $filesize . ' ' . $filename . "\n";
}
close(FH);
system("git add $controlsfile");
print 'Create controls File succesfully' . "\n";
exit 0;