~ubuntu-branches/ubuntu/utopic/gitolite3/utopic

« back to all changes in this revision

Viewing changes to src/triggers/post-compile/update-git-configs

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2013-05-18 17:59:21 UTC
  • Revision ID: package-import@ubuntu.com-20130518175921-ac4xe6vd0jtxvjot
Tags: upstream-3.5.1+4
ImportĀ upstreamĀ versionĀ 3.5.1+4

Show diffs side-by-side

added added

removed removed

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