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

« back to all changes in this revision

Viewing changes to src/commands/help

  • 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
use strict;
 
3
use warnings;
 
4
 
 
5
use lib $ENV{GL_LIBDIR};
 
6
use Gitolite::Rc;
 
7
use Gitolite::Common;
 
8
 
 
9
=for usage
 
10
Usage:  ssh git@host help       # via ssh
 
11
        gitolite help           # directly on server command line
 
12
 
 
13
Prints a list of custom commands available at this gitolite installation.
 
14
 
 
15
Each command has its own help, accessed by passing it '-h' again.
 
16
=cut
 
17
 
 
18
usage() if @ARGV;
 
19
 
 
20
my $user = $ENV{GL_USER} || '';
 
21
print "hello" . ( $user ? " $user" : "" ) . ", this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n";
 
22
 
 
23
print "list of " . ( $user ? "remote" : "gitolite" ) . " commands available:\n\n";
 
24
 
 
25
my %list = (list_x( $ENV{GL_BINDIR}), list_x($rc{LOCAL_CODE} || ''));
 
26
for (sort keys %list) {
 
27
    print "\t$list{$_}" if $ENV{D};
 
28
    print "\t$_\n" if not $user or $rc{COMMANDS}{$_};
 
29
}
 
30
 
 
31
print "\n";
 
32
 
 
33
exit 0;
 
34
 
 
35
# ------------------------------------------------------------------------------
 
36
sub list_x {
 
37
    my $d = shift;
 
38
    return unless $d;
 
39
    return unless -d "$d/commands";
 
40
    _chdir "$d/commands";
 
41
    return map { $_ => $d } grep { -x $_ } map { chomp; s(^./)(); $_ } `find . -type f -o -type l|sort`;
 
42
}