From 3f7edfea672c6736ff9a85b6064bde5524c0d707 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Mon, 19 Mar 2012 21:34:07 +0530 Subject: [PATCH] usage() needed some minor fixes... --- src/Gitolite/Common.pm | 10 +++------- src/commands/access | 11 ++--------- src/commands/help | 2 ++ src/commands/info | 2 +- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/Gitolite/Common.pm b/src/Gitolite/Common.pm index a80b2db..6dbc6e3 100644 --- a/src/Gitolite/Common.pm +++ b/src/Gitolite/Common.pm @@ -84,15 +84,11 @@ sub _die { sub usage { _warn(shift) if @_; - my ( $script, $function ) = ( caller(1) )[ 1, 3 ]; - if ( not $script ) { - $script = (caller)[1]; - $function = 'usage'; - } - dbg( "u s a g e", $script, $function ); + my $script = (caller)[1]; + my $function = ( ( ( caller(1) )[3] ) || ( ( caller(0) )[3] ) ); $function =~ s/.*:://; my $code = slurp($script); - $code =~ /^=for $function(.*?)^=cut/sm; + $code =~ /^=for $function\b(.*?)^=cut/sm; say2( $1 ? $1 : "...no usage message in $script" ); exit 1; } diff --git a/src/commands/access b/src/commands/access index f42e147..11d2e9a 100755 --- a/src/commands/access +++ b/src/commands/access @@ -24,15 +24,6 @@ Notes: The 'any' ref is special -- it ignores deny rules (see docs for what this means and exceptions). -Advanced use (examples only): - - gitolite list-phy-repos | gitolite access % gitweb R | grep -v DENIED | cut -f1 > ~/projects.list - # now people can stop thinking gitolite has anything to do with gitweb! - - gitolite list-phy-repos | grep foo | - perl -lne 'print "$_ gitweb\n$_ daemon"' | - gitolite access % % R | grep -v DENIED | cut -f1 > insecure.repos - For each case where access is not denied, one line is printed like this: reponameusernameaccess rights @@ -40,6 +31,8 @@ For each case where access is not denied, one line is printed like this: This is orders of magnitude faster than running the command multiple times; you'll notice if you have more than a hundred or so repos. +Advanced uses: see src/commands/post-compile/update-git-daemon-access-list for +a good example. =cut # TODO: deal with "C", call it ^C diff --git a/src/commands/help b/src/commands/help index 211b73a..cb7b2f3 100755 --- a/src/commands/help +++ b/src/commands/help @@ -12,6 +12,8 @@ Usage: gitolite help Prints a list of custom commands available at this gitolite installation. =cut +usage() if @ARGV; + my $user = $ENV{GL_USER} || ''; print "hello" . ( $user ? " $user" : "" ) . ", this is gitolite3 " . version() . " on git " . substr( `git --version`, 12 ) . "\n"; diff --git a/src/commands/info b/src/commands/info index 92efe81..5a50e9e 100755 --- a/src/commands/info +++ b/src/commands/info @@ -29,7 +29,7 @@ GetOptions( 'h' => \$help, ) or usage(); -usage() if @ARGV > 1; +usage() if @ARGV > 1 or $help; $patt = shift || '.'; my $user = $ENV{GL_USER} or _die "GL_USER not set";