/
update-git-configs
executable file
·57 lines (44 loc) · 1.59 KB
/
update-git-configs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# update git-config entries in each repo
# ----------------------------------------------------------------------
use FindBin;
use lib $ENV{GL_LIBDIR};
use Gitolite::Rc;
use Gitolite::Common;
use Gitolite::Conf::Load;
use strict;
use warnings;
my $RB = $rc{GL_REPO_BASE};
_chdir($RB);
# ----------------------------------------------------------------------
# skip if arg-0 is POST_CREATE and no arg-2 (user name) exists; this means
# it's been triggered by a *normal* (not "wild") repo creation, which in turn
# means a POST_COMPILE should be following so there's no need to waste time
# running this once for each new repo
exit 0 if @ARGV and $ARGV[0] eq 'POST_CREATE' and not $ARGV[2];
# ----------------------------------------------------------------------
# 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)
my $lpr = list_phy_repos();
for my $pr (@$lpr) {
fixup_config($pr);
}
sub fixup_config {
my $pr = shift;
my $creator = creator($pr);
my $gc = git_config( $pr, '.', 1 );
while ( my ( $key, $value ) = each( %{$gc} ) ) {
next if $key =~ /^gitolite-options\./;
if ( $value ne "" ) {
system( "git", "config", "--file", "$RB/$pr.git/config", $key, $value );
} else {
system( "git", "config", "--file", "$RB/$pr.git/config", "--unset-all", $key );
}
}
}