optimise the single-repo POST_CREATE cases a bit...
[gitolite.git] / src / gitolite
blob4a4cbf5873452489ae64e40f597f90353dc39bf2
1 #!/usr/bin/perl
3 # all gitolite CLI tools run as sub-commands of this command
4 # ----------------------------------------------------------------------
6 =for args
7 Usage: gitolite [sub-command] [options]
9 The following built-in subcommands are available; they should all respond to
10 '-h' if you want further details on each:
12 setup 1st run: initial setup; all runs: hook fixups
13 compile compile gitolite.conf
15 query-rc get values of rc variables
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
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'
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
34 # ----------------------------------------------------------------------
36 use FindBin;
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;
44 use strict;
45 use warnings;
47 # ----------------------------------------------------------------------
49 my ( $command, @args ) = @ARGV;
50 gl_log( 'cli', 'gitolite', @ARGV ) if -d $rc{GL_ADMIN_BASE} and $$ == ( $ENV{GL_TID} || 0 );
51 args();
53 # the first two commands need options via @ARGV, as they have their own
54 # GetOptions calls and older perls don't have 'GetOptionsFromArray'
56 if ( $command eq 'setup' ) {
57 shift @ARGV;
58 require Gitolite::Setup;
59 Gitolite::Setup->import;
60 setup();
62 } elsif ( $command eq 'query-rc' ) {
63 shift @ARGV;
64 query_rc(); # doesn't return
66 # the rest don't need @ARGV per se
68 } elsif ( $command eq 'compile' ) {
69 require Gitolite::Conf;
70 Gitolite::Conf->import;
71 compile(@args);
73 } elsif ( $command eq 'trigger' ) {
74 trigger(@args);
76 } elsif ( my $c = _which( "commands/$command", 'x' ) ) {
77 trace( 2, "attempting gitolite command $c" );
78 _system( $c, @args );
80 } elsif ( $command eq 'list-phy-repos' ) {
81 _chdir( $rc{GL_REPO_BASE} );
82 print "$_\n" for ( @{ list_phy_repos(@args) } );
84 } elsif ( $command =~ /^list-/ ) {
85 trace( 2, "attempting lister command $command" );
86 require Gitolite::Conf::Load;
87 Gitolite::Conf::Load->import;
88 my $fn = lister_dispatch($command);
89 print "$_\n" for ( @{ $fn->(@args) } );
91 } else {
92 _die "unknown gitolite sub-command";
95 gl_log('END') if $$ == $ENV{GL_TID};
97 exit 0;
99 sub args {
100 usage() if not $command or $command eq '-h';
103 # ----------------------------------------------------------------------