From 22bd3c8e72893cf744892d3f9799fe8b6ff6573c Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 1 Oct 2011 19:32:21 +0530 Subject: [PATCH] (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) --- conf/example.gitolite.rc | 1 + contrib/adc/rm | 1 + src/gitolite.pm | 32 ++++++++++++++++++++++++++++++-- src/gitolite_rc.pm | 5 ++++- src/gl-compile-conf | 8 ++------ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/conf/example.gitolite.rc b/conf/example.gitolite.rc index 6dadb70..0c23364 100644 --- a/conf/example.gitolite.rc +++ b/conf/example.gitolite.rc @@ -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; # ------------------------------------------------------------------------------ diff --git a/contrib/adc/rm b/contrib/adc/rm index 7223a6c..60c0bf7 100755 --- a/contrib/adc/rm +++ b/contrib/adc/rm @@ -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 diff --git a/src/gitolite.pm b/src/gitolite.pm index e39f310..0f520f1 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -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"; diff --git a/src/gitolite_rc.pm b/src/gitolite_rc.pm index 9a31221..71f6d0b 100644 --- a/src/gitolite_rc.pm +++ b/src/gitolite_rc.pm @@ -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 # ------------------------------------------------------------------------------ diff --git a/src/gl-compile-conf b/src/gl-compile-conf index 18d85c6..77e451a 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -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); + } # ----------------------------------------------------------------------------