compile: gitweb/daemon writes are unconditional now

writing the export_ok files and the gitweb project list are now
unconditional.  They're idempotent anyway, and I doubt anyone cared
about all the fancy logic to detect and report *just* the new ones on
each compile.

This paves the way for gitweb ownership to be added later; that code was
becoming too complex otherwise...
This commit is contained in:
Sitaram Chamarty 2009-11-26 19:30:37 +05:30
parent a02a48e8f5
commit 6e0855eb4d

View file

@ -360,67 +360,35 @@ warn "\n\t\t***** WARNING *****\n" .
wrap_chdir("$repo_base_abs"); wrap_chdir("$repo_base_abs");
# get the current project list; note that the file may not yet exist if no
# gitweb access has been specified so far
my %projlist = ();
if (-f $PROJECTS_LIST) {
my $projlist_fh = wrap_open( "<", $PROJECTS_LIST);
while(<$projlist_fh>) {
chomp;
$projlist{$_} = 1;
}
close $projlist_fh;
}
my $projlist_changed = 0;
# daemons first... # daemons first...
for my $repo (sort keys %repos) { for my $repo (sort keys %repos) {
my $export_ok = "$repo.git/git-daemon-export-ok"; my $export_ok = "$repo.git/git-daemon-export-ok";
if ($repos{$repo}{'R'}{'daemon'}) { if ($repos{$repo}{'R'}{'daemon'}) {
unless (-f $export_ok) {
system("touch $export_ok"); system("touch $export_ok");
print "daemon add $repo.git\n";
}
} else { } else {
if (-f $export_ok) {
unlink($export_ok); unlink($export_ok);
print "daemon del $repo.git\n";
}
} }
} }
my %projlist = ();
# ...then gitwebs # ...then gitwebs
for my $repo (sort keys %repos) { for my $repo (sort keys %repos) {
my $desc_file = "$repo.git/description"; my $desc_file = "$repo.git/description";
# note: having a description also counts as enabling gitweb # note: having a description also counts as enabling gitweb
if ($repos{$repo}{'R'}{'gitweb'} or $desc{$repo}) { if ($repos{$repo}{'R'}{'gitweb'} or $desc{$repo}) {
unless ($projlist{"$repo.git"}) {
# not in the old list; add it to the new one
$projlist{"$repo.git"} = 1; $projlist{"$repo.git"} = 1;
$projlist_changed = 1;
print "gitweb add $repo.git\n";
}
# add the description file; no messages to user or error checking :) # add the description file; no messages to user or error checking :)
$desc{$repo} and open(DESC, ">", $desc_file) and print DESC "$desc{$repo}\n" and close DESC; $desc{$repo} and open(DESC, ">", $desc_file) and print DESC "$desc{$repo}\n" and close DESC;
} else { } else {
if ($projlist{"$repo.git"}) {
# delete it from new list
delete $projlist{"$repo.git"};
$projlist_changed = 1;
print "gitweb del $repo.git\n";
}
# delete the description file; no messages to user or error checking :) # delete the description file; no messages to user or error checking :)
unlink $desc_file; unlink $desc_file;
} }
} }
# has there been a change in the gitweb projects list? # update the project list
if ($projlist_changed) {
print "updating gitweb project list $PROJECTS_LIST\n";
my $projlist_fh = wrap_open( ">", $PROJECTS_LIST); my $projlist_fh = wrap_open( ">", $PROJECTS_LIST);
print $projlist_fh join("\n", sort keys %projlist), "\n" if %projlist; print $projlist_fh join("\n", sort keys %projlist), "\n" if %projlist;
close $projlist_fh; close $projlist_fh;
}
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# "compile" ssh authorized_keys # "compile" ssh authorized_keys