summaryrefslogtreecommitdiffstats
path: root/src/commands/creator
blob: 702df73f2186721d40364e06533899672df63a51 (plain)
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
#!/usr/bin/perl
use strict;
use warnings;

use lib $ENV{GL_LIBDIR};
use Gitolite::Rc;
use Gitolite::Common;
use Gitolite::Conf::Load;

=for usage
Usage:  gitolite creator [-n] <reponame> [<username>]

Print the creator name for the repo.  A '-n' suppresses the newline.

When an optional username is supplied, it checks if the user is the creator of
the repo and returns an exit code (shell truth, 0 for success) instead of
printing anything, which makes it possible to do this in shell:

    if gitolite creator someRepo someUser
    then
        ...
=cut

usage() if not @ARGV or $ARGV[0] eq '-h';
my $nl = "\n";
if ( $ARGV[0] eq '-n' ) {
    $nl = '';
    shift;
}
my $repo = shift;
my $user = shift || '';

my $creator = '';
$creator = creator($repo) if not repo_missing($repo);
if ($user) {
    exit 0 if $creator eq $user;
    exit 1;
}
return ( $creator eq $user ) if $user;
print "$creator$nl";