(projects.list changes) collect gitweb-specific stuff in one place

also
  - new "WEB_INTERFACE" variable (defaults to 'gitweb')
  - setup_web_access (write a plain list of repos out)
  - add_del_web_access (add/delete a single repo from projects.list)
This commit is contained in:
Sitaram Chamarty 2011-10-01 19:32:21 +05:30
parent 550982f69e
commit 22bd3c8e72
5 changed files with 38 additions and 9 deletions

View file

@ -27,6 +27,7 @@ $GL_CONF_COMPILED="$GL_ADMINDIR/conf/gitolite.conf-compiled.pm";
# ------------------------------------------------------------------------------
$GL_WILDREPOS = 0;
$PROJECTS_LIST = $ENV{HOME} . "/projects.list";
# $WEB_INTERFACE = "gitweb";
$REPO_UMASK = 0077;
# ------------------------------------------------------------------------------

View file

@ -33,6 +33,7 @@ opt $ARE_YOU_SURE && {
rm -rf $repo.git
echo "$repo is now GONE!"
# gitweb specific; code for cgit users left as an exercise for the reader
cd $HOME
PROJECTS_LIST=$($GL_BINDIR/gl-query-rc PROJECTS_LIST)
export repo

View file

@ -21,6 +21,7 @@ use Exporter 'import';
setup_daemon_access
setup_git_configs
setup_gitweb_access
setup_web_access
shell_out
slurp
special_cmd
@ -276,7 +277,7 @@ sub new_wild_repo {
wrap_print("gl-perms", "$GL_WILDREPOS_DEFPERMS\n") if $GL_WILDREPOS_DEFPERMS;
setup_git_configs($repo, \%git_configs);
setup_daemon_access($repo);
add_del_line ("$repo.git", $PROJECTS_LIST, setup_gitweb_access($repo, '', ''));
add_del_web_access($repo);
wrap_chdir($ENV{HOME});
}
@ -396,7 +397,7 @@ sub get_set_perms
# gitweb and daemon
setup_daemon_access($repo);
# add or delete line (arg1) from file (arg2) depending on arg3
add_del_line ("$repo.git", $PROJECTS_LIST, setup_gitweb_access($repo, '', ''));
add_del_web_access($repo);
}
}
@ -475,6 +476,33 @@ sub setup_daemon_access
# set/unset gitweb access
# ----------------------------------------------------------------------------
sub setup_web_access {
if ($WEB_INTERFACE eq 'gitweb') {
my $projlist = shift;
my $projlist_fh = wrap_open( ">", "$PROJECTS_LIST.$$");
for my $proj (sort keys %{ $projlist }) {
print $projlist_fh "$proj\n";
}
close $projlist_fh;
rename "$PROJECTS_LIST.$$", $PROJECTS_LIST;
} else {
warn "sorry, unknown web interface $WEB_INTERFACE\n";
}
}
sub add_del_web_access {
if ($WEB_INTERFACE eq 'gitweb') {
my $repo = shift;
add_del_line ("$repo.git", $PROJECTS_LIST, setup_gitweb_access($repo, '', ''));
} else {
warn "sorry, unknown web interface $WEB_INTERFACE\n";
}
}
# returns 1 if gitweb access has happened; this is to allow the caller to add
# an entry to the projects.list file
my $desc_file = "description";

View file

@ -21,7 +21,7 @@ use Exporter 'import';
$GL_NO_CREATE_REPOS $GL_NO_DAEMON_NO_GITWEB $GL_NO_SETUP_AUTHKEYS
$GL_PACKAGE_CONF $GL_PACKAGE_HOOKS $GL_PERFLOGT $GL_SITE_INFO
$GL_SLAVE_MODE $GL_WILDREPOS $GL_WILDREPOS_DEFPERMS
$GL_WILDREPOS_PERM_CATS $HTPASSWD_FILE $PROJECTS_LIST $REPO_BASE
$GL_WILDREPOS_PERM_CATS $HTPASSWD_FILE $PROJECTS_LIST $WEB_INTERFACE $REPO_BASE
$REPO_UMASK $RSYNC_BASE $SVNSERVE $UPDATE_CHAINS_TO $AUTH_OPTIONS
$GL_HOSTNAME
@ -57,6 +57,9 @@ $ADC_CMD_ARGS_PATT=qr(^[0-9a-zA-Z._\@/+:-]*$);
# maximum number of output lines from info under GL_BIG_CONFIG
$BIG_INFO_CAP = 20;
# default values for stuff that may be missing in the RC file
$WEB_INTERFACE = 'gitweb';
# ------------------------------------------------------------------------------
# bring in the rc vars and allow querying them
# ------------------------------------------------------------------------------

View file

@ -569,12 +569,8 @@ for my $repo (@phy_repos) {
# write out the project list, but not if GL_NO_DAEMON_NO_GITWEB is set
unless ($GL_NO_DAEMON_NO_GITWEB) {
my $projlist_fh = wrap_open( ">", "$PROJECTS_LIST.$$");
for my $proj (sort keys %projlist) {
print $projlist_fh "$proj\n";
}
close $projlist_fh;
rename "$PROJECTS_LIST.$$", $PROJECTS_LIST;
setup_web_access(\%projlist);
}
# ----------------------------------------------------------------------------