@@ -11,6 +11,66 @@ use Digest::SHA ();
1111# normally use a new file name. If it's a minor change where it is acceptable
1212# for users to use the old files, then updating the hash can be done instead.
1313
14+ # # regenerate with: perl t/static-files.t --regen
15+
16+ for my $arg (@ARGV ) {
17+ if ( $arg eq ' --regen' ) {
18+ my @roots = qw(
19+ root/static/icons
20+ root/static/images
21+ ) ;
22+
23+ my @files ;
24+
25+ require File::Find;
26+ File::Find::find(
27+ {
28+ no_chdir => 1,
29+ wanted => sub {
30+ return
31+ if -d ;
32+ return
33+ if m {\/\. } || m { ~$} ;
34+
35+ push @files , $_ ;
36+ },
37+ },
38+ @roots ,
39+ );
40+
41+ my %sha = map {
42+ $_ => Digest::SHA-> new(' sha1' )-> addfile( $_ , ' b' )-> hexdigest
43+ } @files ;
44+
45+ my $script = $0 ;
46+ $script = " ./$script "
47+ unless $script =~ m { ^/} ;
48+
49+ open my $fh , ' +<' , $script
50+ or die ;
51+
52+ while ( my $line = <$fh > ) {
53+ chomp $line ;
54+ if ( $line eq ' __DATA__' ) {
55+ truncate $fh , tell $fh ;
56+ for my $file ( sort keys %sha ) {
57+ print $fh " $sha {$file } $file \n " ;
58+ }
59+ close $fh ;
60+
61+ @ARGV = ();
62+ do $script or die ;
63+ exit ;
64+ }
65+ }
66+
67+ die " Can't find __DATA__ marker in $0 !\n " ;
68+ }
69+ else {
70+ die " Unsupported option $arg !\n " ;
71+ }
72+ }
73+
1474my %files = reverse map /(\S+)/g, <DATA >;
1575
1676for my $file ( sort keys %files ) {
@@ -23,8 +83,6 @@ for my $file ( sort keys %files ) {
2383
2484done_testing;
2585
26- # # generated with: shasum $(find root/static/icons root/static/images -type f | sort)
27-
2886__DATA__
2987679be699079a90f586aa90dbc79aac14731a226c root/static/icons/apple-touch-icon.png
30889352147a2cb97acb161f21202e9bfec29b6faa30 root/static/icons/favicon-16.ico
@@ -373,6 +431,7 @@ fb43b99a721b83aeebf528977f3df7083a69289e root/static/images/sponsors/perl-caree
3734315cdd9d7bda9936c0ab678063a93df341fd37acb1 root/static/images/sponsors/perl_logo.png
374432e691cd3eb125c4b9e157a083a1c0a5f14e5a692a root/static/images/sponsors/qah-2014.png
375433bb659e08ba1966a9e6d90f9969ce89dd8c6a61b7 root/static/images/sponsors/servercentral.png
434+ b22714f31bf7817c297cf6670fa27c0fe53e9897 root/static/images/sponsors/sonic.png
376435f251ab8c5c58c9c87bbd2e6042d9b2574cd0bc8b root/static/images/sponsors/speedchilli.png
37743628b210ec069326d1914b54186854e278b874e08e root/static/images/sponsors/travis-ci.png
378437d1756602e3883c084a901338b96d8a03b8b540b9 root/static/images/sponsors/vienna.pm.jpeg
0 commit comments