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

« back to all changes in this revision

Viewing changes to src/gitolite

  • 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
# all gitolite CLI tools run as sub-commands of this command
 
4
# ----------------------------------------------------------------------
 
5
 
 
6
=for args
 
7
Usage:  gitolite [sub-command] [options]
 
8
 
 
9
The following built-in subcommands are available; they should all respond to
 
10
'-h' if you want further details on each:
 
11
 
 
12
    setup                       1st run: initial setup; all runs: hook fixups
 
13
    compile                     compile gitolite.conf
 
14
 
 
15
    query-rc                    get values of rc variables
 
16
 
 
17
    list-groups                 list all group names in conf
 
18
    list-users                  list all users/user groups in conf
 
19
    list-repos                  list all repos/repo groups in conf
 
20
    list-phy-repos              list all repos actually on disk
 
21
    list-memberships            list all groups a name is a member of
 
22
    list-members                list all members of a group
 
23
 
 
24
Warnings:
 
25
  - list-users is disk bound and could take a while on sites with 1000s of repos
 
26
  - list-memberships does not check if the name is known; unknown names come
 
27
    back with 2 answers: the name itself and '@all'
 
28
 
 
29
In addition, running 'gitolite help' should give you a list of custom commands
 
30
available.  They may or may not respond to '-h', depending on how they were
 
31
written.
 
32
=cut
 
33
 
 
34
# ----------------------------------------------------------------------
 
35
 
 
36
use FindBin;
 
37
 
 
38
BEGIN { $ENV{GL_BINDIR} = $FindBin::RealBin; }
 
39
BEGIN { $ENV{GL_LIBDIR} = "$ENV{GL_BINDIR}/lib"; }
 
40
use lib $ENV{GL_LIBDIR};
 
41
use Gitolite::Rc;
 
42
use Gitolite::Common;
 
43
 
 
44
use strict;
 
45
use warnings;
 
46
 
 
47
# ----------------------------------------------------------------------
 
48
 
 
49
my ( $command, @args ) = @ARGV;
 
50
gl_log( 'cli', 'gitolite', @ARGV ) if -d $rc{GL_ADMIN_BASE} and $$ == ( $ENV{GL_TID} || 0 );
 
51
args();
 
52
 
 
53
# the first two commands need options via @ARGV, as they have their own
 
54
# GetOptions calls and older perls don't have 'GetOptionsFromArray'
 
55
 
 
56
if ( $command eq 'setup' ) {
 
57
    shift @ARGV;
 
58
    require Gitolite::Setup;
 
59
    Gitolite::Setup->import;
 
60
    setup();
 
61
 
 
62
} elsif ( $command eq 'query-rc' ) {
 
63
    shift @ARGV;
 
64
    query_rc();    # doesn't return
 
65
 
 
66
# the rest don't need @ARGV per se
 
67
 
 
68
} elsif ( $command eq 'compile' ) {
 
69
    require Gitolite::Conf;
 
70
    Gitolite::Conf->import;
 
71
    compile(@args);
 
72
 
 
73
} elsif ( $command eq 'trigger' ) {
 
74
    trigger(@args);
 
75
 
 
76
} elsif ( my $c = _which("commands/$command", 'x' ) ) {
 
77
    trace( 2, "attempting gitolite command $c" );
 
78
    _system( $c, @args );
 
79
    exit 0;
 
80
 
 
81
} elsif ( $command eq 'list-phy-repos' ) {
 
82
    _chdir( $rc{GL_REPO_BASE} );
 
83
    print "$_\n" for ( @{ list_phy_repos(@args) } );
 
84
 
 
85
} elsif ( $command =~ /^list-/ ) {
 
86
    trace( 2, "attempting lister command $command" );
 
87
    require Gitolite::Conf::Load;
 
88
    Gitolite::Conf::Load->import;
 
89
    my $fn = lister_dispatch($command);
 
90
    print "$_\n" for ( @{ $fn->(@args) } );
 
91
 
 
92
} else {
 
93
    _die "unknown gitolite sub-command";
 
94
}
 
95
 
 
96
gl_log('END') if $$ == $ENV{GL_TID};
 
97
 
 
98
sub args {
 
99
    usage() if not $command or $command eq '-h';
 
100
}
 
101
 
 
102
# ----------------------------------------------------------------------