'writes' -> 'writable', order of arguments changed

This commit is contained in:
Sitaram Chamarty 2012-03-27 19:28:56 +05:30
parent cc8b10483b
commit 2bec551009
4 changed files with 12 additions and 13 deletions

53
src/commands/writable Executable file
View file

@ -0,0 +1,53 @@
#!/usr/bin/perl
use strict;
use warnings;
use lib $ENV{GL_BINDIR};
use Gitolite::Easy;
=for usage
Usage: gitolite writable <reponame>|@all on|off
'on' enables, 'off' disables, writes (pushes) to the named repo or all repos.
With 'off', any subsequent text is taken to be the message to be shown to
users when their pushes get rejected. If it is not supplied, it will take it
from STDIN; this allows longer messages.
=cut
usage() if not @ARGV or @ARGV < 2 or $ARGV[0] eq '-h';
usage() if $ARGV[1] ne 'on' and $ARGV[1] ne 'off';
my $repo = shift;
my $on = ( shift eq 'on' );
if ( $repo eq '@all' ) {
die "you are not authorized\n" if $ENV{GL_USER} and not is_admin();
} else {
die "you are not authorized\n" if $ENV{GL_USER} and not owns($repo);
}
my $msg = join( " ", @ARGV );
# try STDIN only if no msg found in args *and* it's an 'off' command
if ( not $msg and not $on ) {
say2 "...please type the message to be shown to users:";
$msg = join( "", <> );
}
my $sf = ".gitolite.down";
my $rb = $ENV{GL_REPO_BASE};
if ( $repo eq '@all' ) {
target( $ENV{HOME} );
} else {
target("$rb/$repo.git");
}
sub target {
my $repodir = shift;
if ($on) {
unlink "$repodir/$sf";
} else {
_print( "$repodir/$sf", $msg );
}
}