gitolite/src/triggers/post-compile/update-git-configs

51 lines
1.2 KiB
Plaintext
Raw Normal View History

2012-03-19 11:45:21 +01:00
#!/usr/bin/perl
# update git-config entries in each repo
# ----------------------------------------------------------------------
use FindBin;
use lib $ENV{GL_LIBDIR};
2012-03-19 11:45:21 +01:00
use Gitolite::Rc;
use Gitolite::Common;
use Gitolite::Conf::Load;
use strict;
use warnings;
my $RB = $rc{GL_REPO_BASE};
_chdir($RB);
2012-04-22 17:55:54 +02:00
# ----------------------------------------------------------------------
# if called from POST_CREATE, we have only a single repo to worry about
if (@ARGV and $ARGV[0] eq 'POST_CREATE') {
my $repo = $ARGV[1];
fixup_config($repo);
exit 0;
}
# ----------------------------------------------------------------------
# else it's all repos (i.e., called from POST_COMPILE)
2012-03-19 11:45:21 +01:00
my $lpr = list_phy_repos();
for my $pr (@$lpr) {
2012-04-22 17:55:54 +02:00
fixup_config($pr);
}
sub fixup_config {
my $pr = shift;
my $gc = git_config( $pr, '.', 1 );
while ( my ( $key, $value ) = each( %{$gc} ) ) {
2012-03-19 11:45:21 +01:00
next if $key =~ /^gitolite-options\./;
if ( $value ne "" ) {
2012-03-19 11:45:21 +01:00
$value =~ s/%GL_REPO/$pr/g;
system( "git", "config", "--file", "$RB/$pr.git/config", $key, $value );
2012-03-19 11:45:21 +01:00
} else {
system( "git", "config", "--file", "$RB/$pr.git/config", "--unset-all", $key );
2012-03-19 11:45:21 +01:00
}
}
}