allow defining and checking 'config gitolite-options.foo = bar' type keys

This commit is contained in:
Sitaram Chamarty 2011-10-07 19:27:28 +05:30
parent 77f0b2da0e
commit a1270ba778
2 changed files with 19 additions and 0 deletions

View file

@ -450,6 +450,7 @@ sub setup_git_configs
# and the final step is the repo config: {"key"} = "value" # and the final step is the repo config: {"key"} = "value"
my $rc = $rch{$seq}; my $rc = $rch{$seq};
while ( my ($key, $value) = each(%{ $rc }) ) { while ( my ($key, $value) = each(%{ $rc }) ) {
next if $key =~ /^gitolite-options\./;
if ($value ne "") { if ($value ne "") {
$value =~ s/^['"](.*)["']$/$1/; $value =~ s/^['"](.*)["']$/$1/;
system("git", "config", $key, $value); 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 # get memberships
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------

View file

@ -246,6 +246,7 @@ sub parse_conf_line
{ {
my ($key, $value) = ($1, $2); my ($key, $value) = ($1, $2);
my @validkeys = split(' ', ($GL_GITCONFIG_KEYS || '') ); my @validkeys = split(' ', ($GL_GITCONFIG_KEYS || '') );
push @validkeys, "gitolite-options\\..*";
my @matched = grep { $key =~ /^$_$/ } @validkeys; 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); 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 for my $repo (@{ $repos_p }) # each repo in the current stanza