3 # Remove all projects' ctags that are not a valid_tag (--dry-run shows invalid tags)
11 use Girocco
::Util
qw(valid_tag);
13 my $rr = $Girocco::Config
::reporoot
;
14 -d
$rr or die "No such directory $rr\n";
15 my $gwic = $Girocco::Config
::projlist_cache_dir
. "/gitweb.index.cache";
17 eval { $cache = retrieve
($gwic); 1; } or die "Could not load cache file $gwic\n";
20 # [ "format string", [[project hash refs in project name order], {project name => hashref}]]
22 # Each project hash ref has:
23 # owner => project owner name
24 # descr_long => project one liner description (from description file)
25 # age_epoch => time of last change (seconds since epoch)
26 # ctags => hash ref of tag => count (not present if ctags not enabled)
27 # path => $Girocco::Config::reporoot relative path to repository
28 # descr => truncated version of descr_long (typically 29-34 characters)
30 @ARGV == 0 || @ARGV == 1 && $ARGV[0] eq "--dry-run"
31 or die "Usage: clean-tags.pl [--dry-run]\n";
38 if (-f
"$rr/$_[1]/ctags/$_[0]") {
43 printf "%s:\t%s\n", $p, $_[0];
45 unlink("$rr/$_[1]/ctags/$_[0]")
46 or warn "failed to remove '$rr/$_[1]/ctags/$_[0]': $!\n";
51 foreach my $proj (@
{$cache->[1][0]}) {
52 ref($proj) eq 'HASH' && ref($proj->{ctags
}) eq 'HASH' or next;
53 while (my ($k,$v) = each(%{$proj->{ctags
}})) {
54 valid_tag
($k) or kill_tag
($k, $proj->{path
});
58 printf "%s %d tag file(s)\n", ($dryrun?
"Would remove":"Removed"), $killcount;