From a1270ba77829183bff0ab7e13c5cb846e22e8b97 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 7 Oct 2011 19:27:28 +0530 Subject: [PATCH] allow defining and checking 'config gitolite-options.foo = bar' type keys --- src/gitolite.pm | 18 ++++++++++++++++++ src/gl-compile-conf | 1 + 2 files changed, 19 insertions(+) diff --git a/src/gitolite.pm b/src/gitolite.pm index 10cfbef..afabbda 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -450,6 +450,7 @@ sub setup_git_configs # and the final step is the repo config: {"key"} = "value" my $rc = $rch{$seq}; while ( my ($key, $value) = each(%{ $rc }) ) { + next if $key =~ /^gitolite-options\./; if ($value ne "") { $value =~ s/^['"](.*)["']$/$1/; system("git", "config", $key, $value); @@ -854,6 +855,23 @@ sub check_repo_write_enabled { } } +sub check_config_key { + my($repo, $key) = @_; + my @ret = (); + + # look through $git_configs{$repo} and return an array of the values of + # all second level keys that match $key. To understand "second level", + # you need to remember that %git_configs has elements like this: + # $git_config{'reponame'}{sequence_number}{key} = value + + for my $s (sort { $a <=> $b } keys %{ $git_configs{$repo} }) { + for my $k (keys %{ $git_configs{$repo}{$s} }) { + push @ret, $git_configs{$repo}{$s}{$k} if $k =~ /^$key$/; + } + } + return @ret; +} + # ---------------------------------------------------------------------------- # get memberships # ---------------------------------------------------------------------------- diff --git a/src/gl-compile-conf b/src/gl-compile-conf index d812b06..910a2a9 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -246,6 +246,7 @@ sub parse_conf_line { my ($key, $value) = ($1, $2); my @validkeys = split(' ', ($GL_GITCONFIG_KEYS || '') ); + push @validkeys, "gitolite-options\\..*"; my @matched = grep { $key =~ /^$_$/ } @validkeys; die "$ABRT git config $key not allowed\ncheck GL_GITCONFIG_KEYS in the rc file for how to allow it\n" if (@matched < 1); for my $repo (@{ $repos_p }) # each repo in the current stanza