mod-NUKI/hooks/pre-commit

42 lines
989 B
Plaintext
Raw Normal View History

2021-11-26 18:45:29 +00:00
#!/usr/bin/perl -w
use File::Basename;
use POSIX qw(strftime);
use strict;
2021-12-10 20:59:48 +00:00
my @filenames = ( 'FHEM/73_NUKIBridge.pm',
'FHEM/74_NUKIDevice.pm',
'lib/FHEM/Devices/Nuki/Bridge.pm',
'lib/FHEM/Devices/Nuki/Device.pm'
2021-11-26 18:45:29 +00:00
);
2021-12-10 20:59:48 +00:00
my $controlsfile = 'controls_NukiSmart.txt';
2021-11-26 18:45:29 +00:00
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;