#!/usr/pkg/bin/perl
use strict;
use warnings;

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

=for usage
create -- create a wild repo.

Usage:
    ssh git@host create <repo>
=cut

usage() if @ARGV != 1 or $ARGV[0] eq '-h';

$ENV{GL_USER} or _die "GL_USER not set";

my $repo = shift;
_die "invalid repo '$repo'" unless $repo =~ $REPONAME_PATT;

my $ret = access( $repo, $ENV{GL_USER}, '^C', 'any' );
_die "repo already exists or you are not authorised to create it" if $ret =~ /DENIED/;

new_wild_repo( $repo, $ENV{GL_USER}, 'create' );
gl_log( 'create', $repo, $ENV{GL_USER}, 'create' );
