From 3403d40d0e0a478252fa4111a44fb42218f92f15 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Mon, 7 Dec 2009 22:20:29 +0200 Subject: [PATCH] Add support for repo configurations Git repository configurations can be set/unset by declaring "config" lines in "repo" stanzas in gitolite.conf. For example: repo gitolite config hooks.mailinglist = gitolite-commits@example.tld config hooks.emailprefix = "[gitolite] " config foo.bar = "" config foo.baz = The firs two set (override) the values. Double quotes must be used to preserve preceding spaces. Third one sets an empty value and the last removes all keys. Signed-off-by: Teemu Matilainen --- src/gl-compile-conf | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gl-compile-conf b/src/gl-compile-conf index 7526da5..138249d 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -101,6 +101,9 @@ my %rurp_seen = (); # catch usernames<->pubkeys mismatches; search for "lint" below my %user_list = (); +# repo configurations +my %repo_config = (); + # gitweb descriptions and owners; plain text, keyed by "$repo.git" my %desc = (); my %owner = (); @@ -244,6 +247,16 @@ sub parse_conf_file } } } + # configuration + elsif (/^config (.+) = ?(.*)/) + { + my ($key, $value) = ($1, $2); + die "$WARN $fragment attempting to set repo configuration\n" if $fragment ne 'master'; + for my $repo (@repos) # each repo in the current stanza + { + $repo_config{$repo}{$key} = $value; + } + } # very simple syntax for the gitweb description of repo; one of: # reponame = "some description string" # reponame "owner name" = "some description string" @@ -338,6 +351,22 @@ warn "\n\t\t***** WARNING *****\n" . "\t\"git version dependency\" in doc/3-faq-tips-etc.mkd\n" if $git_version < 10602; # that's 1.6.2 to you +# ---------------------------------------------------------------------------- +# update repo configurations +# ---------------------------------------------------------------------------- + +for my $repo (keys %repo_config) { + wrap_chdir("$repo_base_abs/$repo.git"); + while ( my ($key, $value) = each(%{ $repo_config{$repo} }) ) { + if ($value) { + $value =~ s/^"(.*)"$/$1/; + system("git", "config", $key, $value); + } else { + system("git", "config", "--unset-all", $key); + } + } +} + # ---------------------------------------------------------------------------- # handle gitweb and daemon # ----------------------------------------------------------------------------