Improve remove_stale.pl
Hi,
this patch reads .staleignore files to keep specified files (should
have know about this script before ;))
Denis
Index: remove_stale.pl
===================================================================
RCS file: /cvs/webwml/webwml/remove_stale.pl,v
retrieving revision 1.7
diff -u -r1.7 remove_stale.pl
--- remove_stale.pl 2001/07/31 22:39:19 1.7
+++ remove_stale.pl 2001/07/31 23:22:50
@@ -56,6 +56,15 @@
return 0;
}
+ # Read .staleignore if it exists
+ my @ignores = ();
+ if (open IGNORE, "$directory/.staleignore")
+ {
+ @ignores = <IGNORE>;
+ chomp(@ignores);
+ close IGNORE;
+ }
+
my @wmlfiles = ();
my @htmlfiles = ();
while (<ENTRIES>)
@@ -81,7 +90,7 @@
# file, except in the english dir
if (-f $direntry && $direntry =~ /\.html$/ && $direntry !~ /sitemap\..*\.html$/)
{
- my ($haswml, $incvs) = (0, 0);
+ my ($haswml, $incvs, $ign) = (0, 0, 0);
# Check for WML file.
my $source = $direntry;
@@ -115,6 +124,17 @@
}
unless ($haswml || $incvs)
+ {
+ # Check if HTML file is listed in .staleignore
+ my ($file) = ($direntry =~ m'([^/]+)$');
+ my $ignore;
+ IGNORES: foreach $ignore (@ignores) {
+ $ign = 1, last IGNORES
+ if $ignore eq $file;
+ }
+ }
+
+ unless ($haswml || $incvs || $ign)
{
# File has no reason for being here.
$count ++;
Reply to: