install/test made easy (WARNING: read below)
(1) testing is very easy, just run this from a clone t/g3-clean-install-setup-test BUT BE WARNED THIS IS DESTRUCTIVE; details in t/WARNING (2) install is equally simple; see 'INSTALL' in the main directory
This commit is contained in:
parent
acb2f8fe8e
commit
379b0c9549
177
Gitolite/Rc.pm
177
Gitolite/Rc.pm
|
@ -1,177 +0,0 @@
|
|||
package Gitolite::Rc;
|
||||
|
||||
# everything to do with 'rc'. Also defines some 'constants'
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
@EXPORT = qw(
|
||||
%rc
|
||||
glrc
|
||||
query_rc
|
||||
|
||||
$ADC_CMD_ARGS_PATT
|
||||
$REF_OR_FILENAME_PATT
|
||||
$REPONAME_PATT
|
||||
$REPOPATT_PATT
|
||||
$USERNAME_PATT
|
||||
);
|
||||
|
||||
use Exporter 'import';
|
||||
use Getopt::Long;
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
our %rc;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# variables that are/could be/should be in the rc file
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
$rc{GL_ADMIN_BASE} = "$ENV{HOME}/.gitolite";
|
||||
$rc{GL_REPO_BASE} = "$ENV{HOME}/repositories";
|
||||
|
||||
# variables that should probably never be changed
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
$ADC_CMD_ARGS_PATT = qr(^[0-9a-zA-Z._\@/+:-]*$);
|
||||
$REF_OR_FILENAME_PATT = qr(^[0-9a-zA-Z][0-9a-zA-Z._\@/+ :,-]*$);
|
||||
$REPONAME_PATT = qr(^\@?[0-9a-zA-Z][0-9a-zA-Z._\@/+-]*$);
|
||||
$REPOPATT_PATT = qr(^\@?[0-9a-zA-Z[][\\^.$|()[\]*+?{}0-9a-zA-Z._\@/,-]*$);
|
||||
$USERNAME_PATT = qr(^\@?[0-9a-zA-Z][0-9a-zA-Z._\@+-]*$);
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $current_data_version = "3.0";
|
||||
|
||||
my $rc = glrc('filename');
|
||||
do $rc if -r $rc;
|
||||
# let values specified in rc file override our internal ones
|
||||
@rc{ keys %RC } = values %RC;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $glrc_default_text = '';
|
||||
{
|
||||
local $/ = undef;
|
||||
$glrc_default_text = <DATA>;
|
||||
}
|
||||
|
||||
sub glrc {
|
||||
my $cmd = shift;
|
||||
if ( $cmd eq 'default-filename' ) {
|
||||
trace( 1, "..should happen only on first run" );
|
||||
return "$ENV{HOME}/.gitolite.rc";
|
||||
} elsif ( $cmd eq 'default-text' ) {
|
||||
trace( 1, "..should happen only on first run" );
|
||||
return $glrc_default_text if $glrc_default_text;
|
||||
_die "rc file default text not set; this should not happen!";
|
||||
} elsif ( $cmd eq 'filename' ) {
|
||||
# where is the rc file?
|
||||
trace(4);
|
||||
|
||||
# search $HOME first
|
||||
return "$ENV{HOME}/.gitolite.rc" if -f "$ENV{HOME}/.gitolite.rc";
|
||||
trace( 2, "$ENV{HOME}/.gitolite.rc not found" );
|
||||
|
||||
# XXX for fedora, we can add the following line, but I would really prefer
|
||||
# if ~/.gitolite.rc on each $HOME was just a symlink to /etc/gitolite.rc
|
||||
# XXX return "/etc/gitolite.rc" if -f "/etc/gitolite.rc";
|
||||
|
||||
return '';
|
||||
} elsif ( $cmd eq 'current-data-version' ) {
|
||||
return $current_data_version;
|
||||
} else {
|
||||
_die "unknown argument to glrc: $cmd";
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# implements 'gitolite query-rc'
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
=for usage
|
||||
|
||||
Usage: gitolite query-rc -a
|
||||
gitolite query-rc <list of rc variables>
|
||||
|
||||
Example:
|
||||
|
||||
gitolite query-rc GL_ADMIN_BASE GL_UMASK
|
||||
# prints "/home/git/.gitolite<tab>0077" or similar
|
||||
|
||||
gitolite query-rc -a
|
||||
# prints all known variables and values, one per line
|
||||
=cut
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $all = 0;
|
||||
|
||||
sub query_rc {
|
||||
trace( 1, "rc file not found; default should be " . glrc('default-filename') ) if not glrc('filename');
|
||||
|
||||
my @vars = args();
|
||||
|
||||
no strict 'refs';
|
||||
|
||||
if ( $vars[0] eq '-a' ) {
|
||||
for my $e (sort keys %rc) {
|
||||
print "$e=" . ( defined($rc{$e}) ? $rc{$e} : 'undef' ) . "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
our $GL_BINDIR = $ENV{GL_BINDIR};
|
||||
|
||||
print join( "\t", map { $rc{$_} } @vars ) . "\n" if @vars;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
sub args {
|
||||
my $help = 0;
|
||||
|
||||
GetOptions(
|
||||
'all|a' => \$all,
|
||||
'help|h' => \$help,
|
||||
) or usage();
|
||||
|
||||
usage("'-a' cannot be combined with other arguments") if $all and @ARGV;
|
||||
return '-a' if $all;
|
||||
usage() if not @ARGV or $help;
|
||||
return @ARGV;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
__DATA__
|
||||
# configuration variables for gitolite
|
||||
|
||||
# PLEASE READ THE DOCUMENTATION BEFORE EDITING OR ASKING QUESTIONS
|
||||
|
||||
# this file is in perl syntax. However, you do NOT need to know perl to edit
|
||||
# it; it should be fairly self-explanatory and easy to maintain
|
||||
|
||||
%RC = (
|
||||
GL_UMASK => 0077,
|
||||
GL_GITCONFIG_KEYS => "",
|
||||
);
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# per perl rules, this should be the last line in such a file:
|
||||
1;
|
||||
|
||||
# Local variables:
|
||||
# mode: perl
|
||||
# End:
|
||||
# vim: set syn=perl:
|
17
INSTALL
Normal file
17
INSTALL
Normal file
|
@ -0,0 +1,17 @@
|
|||
1. Clone the repo and copy src somewhere (or leave it where it is, if you're
|
||||
sure no one will 'git pull' on a running system!)
|
||||
|
||||
cp -a src /some/full/path
|
||||
|
||||
2. (Optional) Make a symlink for the single executable 'gitolite' to
|
||||
somewhere in `$PATH`
|
||||
|
||||
ln -sf /full/path/to/some/damn/place/gitolite $HOME/bin
|
||||
|
||||
3. Run setup. That is, either run:
|
||||
|
||||
gitolite setup -a YourName -pk /tmp/YourName.pub
|
||||
|
||||
or, if you did not do step 2, run:
|
||||
|
||||
/some/full/path/src/gitolite -a YourName -pk /tmp/YourName.pub
|
35
g3-info
35
g3-info
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# gitolite shell, invoked from ~/.ssh/authorized_keys
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
BEGIN {
|
||||
# find and set bin dir
|
||||
$ENV{GL_BINDIR} = "$ENV{HOME}/bin";
|
||||
}
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Conf::Load;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $user = shift or die;
|
||||
my $aa;
|
||||
my $ref = 'any';
|
||||
|
||||
my $ret;
|
||||
while (<>) {
|
||||
chomp;
|
||||
|
||||
my $perm = '';
|
||||
for $aa (qw(R W C)) {
|
||||
$ret = access($_, $user, $aa, $ref);
|
||||
$perm .= ( $ret =~ /DENIED/ ? " " : " $aa" );
|
||||
}
|
||||
print "$perm\t$_\n" if $perm =~ /\S/;
|
||||
}
|
20
g3-install
20
g3-install
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# this is specific to my test env; you may want to change it
|
||||
|
||||
set -e
|
||||
|
||||
cd /home/g3
|
||||
|
||||
if [ "$1" = "-c" ]
|
||||
then
|
||||
rm -rf .gito* gito* repositories proj* bin
|
||||
mkdir bin
|
||||
cp ~/.ssh/id_rsa.pub ~/.ssh/admin.pub
|
||||
|
||||
cd g3; cp -a gito* Gito* t/glt t/gito* ~/bin
|
||||
gitolite setup -a ${2:-admin} -pk ~/.ssh/admin.pub
|
||||
else
|
||||
cd g3; cp -a gito* Gito* t/glt t/gito* ~/bin
|
||||
gitolite setup
|
||||
fi
|
95
gitolite
95
gitolite
|
@ -1,95 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# all gitolite CLI tools run as sub-commands of this command
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
=for usage
|
||||
Usage: gitolite [sub-command] [options]
|
||||
|
||||
The following subcommands are available; they should all respond to '-h':
|
||||
|
||||
setup 1st run: initial setup; all runs: hook fixups
|
||||
compile compile gitolite.conf
|
||||
query-rc get values of rc variables
|
||||
list-groups list all group names in conf
|
||||
list-users list all users/user groups in conf
|
||||
list-repos list all repos/repo groups in conf
|
||||
list-phy-repos list all repos actually on disk
|
||||
list-memberships list all groups a name is a member of
|
||||
list-members list all members of a group
|
||||
|
||||
Warnings:
|
||||
- list-users is disk bound and could take a while on sites with 1000s of repos
|
||||
- list-memberships does not check if the name is known; unknown names come
|
||||
back with 2 answers: the name itself and '@all'
|
||||
=cut
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
|
||||
BEGIN { $ENV{GL_BINDIR} = $FindBin::Bin; }
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
args();
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
sub args {
|
||||
my ( $command, @args ) = @ARGV;
|
||||
usage() if not $command or $command eq '-h';
|
||||
|
||||
if ( $command eq 'setup' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Setup;
|
||||
Gitolite::Setup->import;
|
||||
setup();
|
||||
} elsif ( $command eq 'compile' ) {
|
||||
shift @ARGV;
|
||||
_die "'gitolite compile' does not take any arguments" if @ARGV;
|
||||
require Gitolite::Conf;
|
||||
Gitolite::Conf->import;
|
||||
compile();
|
||||
} elsif ( $command eq 'query-rc' ) {
|
||||
shift @ARGV;
|
||||
query_rc();
|
||||
} elsif ( $command eq 'list-groups' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_groups() } );
|
||||
} elsif ( $command eq 'list-users' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_users() } );
|
||||
} elsif ( $command eq 'list-repos' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_repos() } );
|
||||
} elsif ( $command eq 'list-phy-repos' ) {
|
||||
shift @ARGV;
|
||||
_chdir( $rc{GL_REPO_BASE} );
|
||||
print "$_\n" for ( @{ list_phy_repos() } );
|
||||
} elsif ( $command eq 'list-memberships' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_memberships() } );
|
||||
} elsif ( $command eq 'list-members' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_members() } );
|
||||
} else {
|
||||
_die "unknown gitolite sub-command";
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ package Gitolite::Common;
|
|||
@EXPORT = qw(
|
||||
print2 dbg _mkdir _open ln_sf tsh_rc sort_u
|
||||
say _warn _chdir _print tsh_text list_phy_repos
|
||||
say2 _die slurp tsh_lines
|
||||
say2 _die _system slurp tsh_lines
|
||||
trace cleanup_conf_line tsh_try
|
||||
usage tsh_run
|
||||
);
|
||||
|
@ -97,6 +97,19 @@ sub _chdir {
|
|||
chdir( $_[0] || $ENV{HOME} ) or _die "chdir $_[0] failed: $!\n";
|
||||
}
|
||||
|
||||
sub _system {
|
||||
if ( system(@_) != 0 ) {
|
||||
say2 "system @_ failed";
|
||||
if ( $? == -1 ) {
|
||||
die "failed to execute: $!\n";
|
||||
} elsif ( $? & 127 ) {
|
||||
die "child died with signal " . ( $? & 127 ) . "\n";
|
||||
} else {
|
||||
die "child exited with value " . ( $? >> 8 ) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub _open {
|
||||
open( my $fh, $_[0], $_[1] ) or _die "open $_[1] failed: $!\n";
|
||||
return $fh;
|
|
@ -12,7 +12,6 @@ package Gitolite::Conf;
|
|||
use Exporter 'import';
|
||||
use Getopt::Long;
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Conf::Sugar;
|
|
@ -9,7 +9,6 @@ package Gitolite::Conf::Explode;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
|
||||
use strict;
|
|
@ -16,7 +16,6 @@ package Gitolite::Conf::Load;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Rc;
|
||||
|
||||
|
@ -108,7 +107,7 @@ sub load_common {
|
|||
_die "parse $cc failed: " . ( $! or $@ ) unless do $cc;
|
||||
|
||||
if ( data_version_mismatch() ) {
|
||||
system("gitolite setup");
|
||||
_system("gitolite setup");
|
||||
_die "parse $cc failed: " . ( $! or $@ ) unless do $cc;
|
||||
_die "data version update failed; this is serious" if data_version_mismatch();
|
||||
}
|
|
@ -22,7 +22,6 @@ use Data::Dumper;
|
|||
$Data::Dumper::Indent = 1;
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Hooks::Update;
|
||||
|
@ -169,7 +168,7 @@ sub new_repo {
|
|||
|
||||
_mkdir("$repo.git");
|
||||
_chdir("$repo.git");
|
||||
system("git init --bare >&2");
|
||||
_system("git init --bare >&2");
|
||||
_chdir( $rc{GL_REPO_BASE} );
|
||||
hook_1($repo);
|
||||
|
|
@ -9,7 +9,6 @@ package Gitolite::Conf::Sugar;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Conf::Explode;
|
|
@ -10,7 +10,6 @@ package Gitolite::Hooks::PostUpdate;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
||||
|
||||
|
@ -30,7 +29,7 @@ sub post_update {
|
|||
local $ENV{GIT_WORK_TREE} = $rc{GL_ADMIN_BASE};
|
||||
tsh_try("git checkout -f --quiet master");
|
||||
}
|
||||
system("$ENV{GL_BINDIR}/gitolite compile");
|
||||
_system("$ENV{GL_BINDIR}/gitolite compile");
|
||||
|
||||
exit 0;
|
||||
}
|
|
@ -10,7 +10,6 @@ package Gitolite::Hooks::Update;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Conf::Load;
|
||||
|
|
@ -7,9 +7,8 @@ package Gitolite::Rc;
|
|||
%rc
|
||||
glrc
|
||||
query_rc
|
||||
version
|
||||
|
||||
$REMOTE_COMMAND_PATT
|
||||
$ADC_CMD_ARGS_PATT
|
||||
$REF_OR_FILENAME_PATT
|
||||
$REPONAME_PATT
|
||||
$REPOPATT_PATT
|
||||
|
@ -37,7 +36,7 @@ $rc{GL_REPO_BASE} = "$ENV{HOME}/repositories";
|
|||
# variables that should probably never be changed
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
$REMOTE_COMMAND_PATT = qr(^[- 0-9a-zA-Z\@\%_=+:,./]*$);
|
||||
$ADC_CMD_ARGS_PATT = qr(^[0-9a-zA-Z._\@/+:-]*$);
|
||||
$REF_OR_FILENAME_PATT = qr(^[0-9a-zA-Z][0-9a-zA-Z._\@/+ :,-]*$);
|
||||
$REPONAME_PATT = qr(^\@?[0-9a-zA-Z][0-9a-zA-Z._\@/+-]*$);
|
||||
$REPOPATT_PATT = qr(^\@?[0-9a-zA-Z[][\\^.$|()[\]*+?{}0-9a-zA-Z._\@/,-]*$);
|
||||
|
@ -49,17 +48,9 @@ my $current_data_version = "3.0";
|
|||
|
||||
my $rc = glrc('filename');
|
||||
do $rc if -r $rc;
|
||||
_die "$rc seems to be for older gitolite" if defined($GL_ADMINDIR);
|
||||
# let values specified in rc file override our internal ones
|
||||
@rc{ keys %RC } = values %RC;
|
||||
|
||||
# testing sometimes requires all of it to be overridden silently; use an
|
||||
# env var that is highly unlikely to appear in real life :)
|
||||
do $ENV{G3T_RC} if exists $ENV{G3T_RC} and -r $ENV{G3T_RC};
|
||||
|
||||
# fix PATH (TODO: do it only if 'gitolite' isn't in PATH)
|
||||
$ENV{PATH} = "$ENV{GL_BINDIR}:$ENV{PATH}";
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
|
@ -76,15 +67,19 @@ my $glrc_default_text = '';
|
|||
sub glrc {
|
||||
my $cmd = shift;
|
||||
if ( $cmd eq 'default-filename' ) {
|
||||
trace( 1, "..should happen only on first run" );
|
||||
return "$ENV{HOME}/.gitolite.rc";
|
||||
} elsif ( $cmd eq 'default-text' ) {
|
||||
trace( 1, "..should happen only on first run" );
|
||||
return $glrc_default_text if $glrc_default_text;
|
||||
_die "rc file default text not set; this should not happen!";
|
||||
} elsif ( $cmd eq 'filename' ) {
|
||||
# where is the rc file?
|
||||
trace(4);
|
||||
|
||||
# search $HOME first
|
||||
return "$ENV{HOME}/.gitolite.rc" if -f "$ENV{HOME}/.gitolite.rc";
|
||||
trace( 2, "$ENV{HOME}/.gitolite.rc not found" );
|
||||
|
||||
# XXX for fedora, we can add the following line, but I would really prefer
|
||||
# if ~/.gitolite.rc on each $HOME was just a symlink to /etc/gitolite.rc
|
||||
|
@ -99,68 +94,56 @@ sub glrc {
|
|||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# implements 'gitolite query-rc' and 'version'
|
||||
# implements 'gitolite query-rc'
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
=for usage
|
||||
|
||||
my $all = 0;
|
||||
my $nonl = 0;
|
||||
|
||||
sub query_rc {
|
||||
|
||||
my @vars = args();
|
||||
|
||||
no strict 'refs';
|
||||
|
||||
if ($all) {
|
||||
for my $e ( sort keys %rc ) {
|
||||
print "$e=" . ( defined( $rc{$e} ) ? $rc{$e} : 'undef' ) . "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
print join( "\t", map { $rc{$_} || '' } @vars ) . ( $nonl ? '' : "\n" ) if @vars;
|
||||
}
|
||||
|
||||
sub version {
|
||||
my $version = '';
|
||||
$version = '(unknown)';
|
||||
for ("$rc{GL_ADMIN_BASE}/VERSION") {
|
||||
$version = slurp($_) if -r $_;
|
||||
}
|
||||
chomp($version);
|
||||
return $version;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
=for args
|
||||
Usage: gitolite query-rc -a
|
||||
gitolite query-rc [-n] <list of rc variables>
|
||||
|
||||
-a print all variables and values
|
||||
-n do not append a newline
|
||||
gitolite query-rc <list of rc variables>
|
||||
|
||||
Example:
|
||||
|
||||
gitolite query-rc GL_ADMIN_BASE UMASK
|
||||
gitolite query-rc GL_ADMIN_BASE GL_UMASK
|
||||
# prints "/home/git/.gitolite<tab>0077" or similar
|
||||
|
||||
gitolite query-rc -a
|
||||
# prints all known variables and values, one per line
|
||||
=cut
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $all = 0;
|
||||
|
||||
sub query_rc {
|
||||
trace( 1, "rc file not found; default should be " . glrc('default-filename') ) if not glrc('filename');
|
||||
|
||||
my @vars = args();
|
||||
|
||||
no strict 'refs';
|
||||
|
||||
if ( $vars[0] eq '-a' ) {
|
||||
for my $e (sort keys %rc) {
|
||||
print "$e=" . ( defined($rc{$e}) ? $rc{$e} : 'undef' ) . "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
print join( "\t", map { $rc{$_} } @vars ) . "\n" if @vars;
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
sub args {
|
||||
my $help = 0;
|
||||
|
||||
GetOptions(
|
||||
'all|a' => \$all,
|
||||
'nonl|n' => \$nonl,
|
||||
'help|h' => \$help,
|
||||
) or usage();
|
||||
|
||||
usage("'-a' cannot be combined with other arguments") if $all and @ARGV;
|
||||
return '-a' if $all;
|
||||
usage() if not $all and not @ARGV or $help;
|
||||
return @ARGV;
|
||||
}
|
||||
|
@ -172,36 +155,14 @@ sub args {
|
|||
__DATA__
|
||||
# configuration variables for gitolite
|
||||
|
||||
# This file is in perl syntax. But you do NOT need to know perl to edit it --
|
||||
# just mind the commas and make sure the brackets and braces stay matched up!
|
||||
# PLEASE READ THE DOCUMENTATION BEFORE EDITING OR ASKING QUESTIONS
|
||||
|
||||
# (Tip: perl allows a comma after the last item in a list also!)
|
||||
# this file is in perl syntax. However, you do NOT need to know perl to edit
|
||||
# it; it should be fairly self-explanatory and easy to maintain
|
||||
|
||||
%RC = (
|
||||
UMASK => 0077,
|
||||
GL_GITCONFIG_KEYS => "",
|
||||
|
||||
# comment out or uncomment as needed
|
||||
# these will run in sequence during the conf file parse
|
||||
SYNTACTIC_SUGAR =>
|
||||
[
|
||||
# 'continuation-lines',
|
||||
],
|
||||
|
||||
# comment out or uncomment as needed
|
||||
# these will run in sequence after post-update
|
||||
POST_COMPILE =>
|
||||
[
|
||||
'post-compile/ssh-authkeys',
|
||||
],
|
||||
|
||||
# comment out or uncomment as needed
|
||||
# these are available to remote users
|
||||
COMMANDS =>
|
||||
{
|
||||
'help' => 1,
|
||||
'info' => 1,
|
||||
},
|
||||
);
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -28,7 +28,6 @@ Later runs:
|
|||
use Exporter 'import';
|
||||
use Getopt::Long;
|
||||
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
||||
use Gitolite::Conf::Store;
|
||||
|
@ -47,7 +46,7 @@ sub setup {
|
|||
setup_gladmin( $admin, $pubkey, $argv );
|
||||
}
|
||||
|
||||
system("$ENV{GL_BINDIR}/gitolite compile");
|
||||
_system("$ENV{GL_BINDIR}/gitolite compile");
|
||||
|
||||
hook_repos(); # all of them, just to be sure
|
||||
}
|
||||
|
@ -141,8 +140,8 @@ sub setup_gladmin {
|
|||
|
||||
$ENV{GIT_WORK_TREE} = $rc{GL_ADMIN_BASE};
|
||||
_chdir("$rc{GL_REPO_BASE}/gitolite-admin.git");
|
||||
system("git add conf/gitolite.conf");
|
||||
system("git add keydir") if $pubkey;
|
||||
_system("git add conf/gitolite.conf");
|
||||
_system("git add keydir") if $pubkey;
|
||||
tsh_try("git config --get user.email") or tsh_run( "git config user.email $ENV{USER}\@" . `hostname` );
|
||||
tsh_try("git config --get user.name") or tsh_run( "git config user.name '$ENV{USER} on '" . `hostname` );
|
||||
tsh_try("git diff --cached --quiet")
|
|
@ -7,6 +7,7 @@ package Gitolite::Test;
|
|||
@EXPORT = qw(
|
||||
try
|
||||
put
|
||||
text
|
||||
);
|
||||
#>>>
|
||||
use Exporter 'import';
|
||||
|
@ -17,6 +18,7 @@ BEGIN {
|
|||
require Gitolite::Test::Tsh;
|
||||
*{'try'} = \&Tsh::try;
|
||||
*{'put'} = \&Tsh::put;
|
||||
*{'text'} = \&Tsh::text;
|
||||
}
|
||||
|
||||
use strict;
|
||||
|
@ -30,11 +32,15 @@ try "
|
|||
DEF reject = /hook declined to update/; /remote rejected.*hook declined/; /error: failed to push some refs to/
|
||||
|
||||
DEF AP_1 = cd ../gitolite-admin; ok or die cant find admin repo clone;
|
||||
DEF AP_2 = AP_1; git add conf keydir; ok; git commit -m %1; ok; /master.* %1/
|
||||
DEF AP_2 = AP_1; git add conf ; ok; git commit -m %1; ok; /master.* %1/
|
||||
DEF ADMIN_PUSH = AP_2 %1; glt push admin origin; ok; gsh; /master -> master/
|
||||
|
||||
./g3-install -c admin
|
||||
mkdir -p $ENV{HOME}/bin
|
||||
ln -sf $ENV{PWD}/src/gitolite $ENV{PWD}/t/glt ~/bin
|
||||
cd; rm -vrf .gito* gito* repositories
|
||||
|
||||
cd tsh_tempdir;
|
||||
";
|
||||
gitolite setup -a admin
|
||||
" or die "could not setup the test environment; errors:\n\n" . text() . "\n\n";
|
||||
|
||||
1;
|
117
src/gitolite
117
src/gitolite
|
@ -3,17 +3,14 @@
|
|||
# all gitolite CLI tools run as sub-commands of this command
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
=for args
|
||||
Usage: gitolite [<sub-command>] [<options>]
|
||||
=for usage
|
||||
Usage: gitolite [sub-command] [options]
|
||||
|
||||
The following built-in subcommands are available; they should all respond to
|
||||
'-h' if you want further details on each:
|
||||
The following subcommands are available; they should all respond to '-h':
|
||||
|
||||
setup 1st run: initial setup; all runs: hook fixups
|
||||
compile compile gitolite.conf
|
||||
|
||||
query-rc get values of rc variables
|
||||
|
||||
list-groups list all group names in conf
|
||||
list-users list all users/user groups in conf
|
||||
list-repos list all repos/repo groups in conf
|
||||
|
@ -25,10 +22,6 @@ Warnings:
|
|||
- list-users is disk bound and could take a while on sites with 1000s of repos
|
||||
- list-memberships does not check if the name is known; unknown names come
|
||||
back with 2 answers: the name itself and '@all'
|
||||
|
||||
In addition, running 'gitolite help' should give you a list of custom commands
|
||||
available. They may or may not respond to '-h', depending on how they were
|
||||
written.
|
||||
=cut
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
@ -45,62 +38,58 @@ use warnings;
|
|||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my ( $command, @args ) = @ARGV;
|
||||
gl_log( 'gitolite', @ARGV ) if -d $rc{GL_ADMIN_BASE};
|
||||
args();
|
||||
|
||||
# the first two commands need options via @ARGV, as they have their own
|
||||
# GetOptions calls and older perls don't have 'GetOptionsFromArray'
|
||||
|
||||
if ( $command eq 'setup' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Setup;
|
||||
Gitolite::Setup->import;
|
||||
setup();
|
||||
|
||||
} elsif ( $command eq 'query-rc' ) {
|
||||
shift @ARGV;
|
||||
query_rc();
|
||||
|
||||
# the rest don't need @ARGV per se
|
||||
|
||||
} elsif ( $command eq 'compile' ) {
|
||||
require Gitolite::Conf;
|
||||
Gitolite::Conf->import;
|
||||
compile(@args);
|
||||
|
||||
} elsif ( $command eq 'trigger' ) {
|
||||
trigger(@args);
|
||||
|
||||
} elsif ( -x "$rc{GL_BINDIR}/commands/$command" ) {
|
||||
trace( 2, "attempting gitolite command $command" );
|
||||
run_command( $command, @args );
|
||||
|
||||
} elsif ( $command eq 'list-phy-repos' ) {
|
||||
_chdir( $rc{GL_REPO_BASE} );
|
||||
print "$_\n" for ( @{ list_phy_repos(@args) } );
|
||||
|
||||
} elsif ( $command =~ /^list-/ ) {
|
||||
trace( 2, "attempting lister command $command" );
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
my $fn = lister_dispatch($command);
|
||||
print "$_\n" for ( @{ $fn->(@args) } );
|
||||
|
||||
} else {
|
||||
_die "unknown gitolite sub-command";
|
||||
}
|
||||
|
||||
sub args {
|
||||
usage() if not $command or $command eq '-h';
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
sub run_command {
|
||||
my $pgm = shift;
|
||||
my $fullpath = "$ENV{GL_BINDIR}/commands/$pgm";
|
||||
_die "$pgm not found or not executable" if not -x $fullpath;
|
||||
_system( $fullpath, @_ );
|
||||
exit 0;
|
||||
sub args {
|
||||
my ( $command, @args ) = @ARGV;
|
||||
usage() if not $command or $command eq '-h';
|
||||
|
||||
if ( $command eq 'setup' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Setup;
|
||||
Gitolite::Setup->import;
|
||||
setup();
|
||||
} elsif ( $command eq 'compile' ) {
|
||||
shift @ARGV;
|
||||
_die "'gitolite compile' does not take any arguments" if @ARGV;
|
||||
require Gitolite::Conf;
|
||||
Gitolite::Conf->import;
|
||||
compile();
|
||||
} elsif ( $command eq 'query-rc' ) {
|
||||
shift @ARGV;
|
||||
query_rc();
|
||||
} elsif ( $command eq 'list-groups' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_groups() } );
|
||||
} elsif ( $command eq 'list-users' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_users() } );
|
||||
} elsif ( $command eq 'list-repos' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_repos() } );
|
||||
} elsif ( $command eq 'list-phy-repos' ) {
|
||||
shift @ARGV;
|
||||
_chdir( $rc{GL_REPO_BASE} );
|
||||
print "$_\n" for ( @{ list_phy_repos() } );
|
||||
} elsif ( $command eq 'list-memberships' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_memberships() } );
|
||||
} elsif ( $command eq 'list-members' ) {
|
||||
shift @ARGV;
|
||||
require Gitolite::Conf::Load;
|
||||
Gitolite::Conf::Load->import;
|
||||
print "$_\n" for ( @{ list_members() } );
|
||||
} else {
|
||||
_die "unknown gitolite sub-command";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
# gitolite shell, invoked from ~/.ssh/authorized_keys
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
BEGIN {
|
||||
# find and set bin dir
|
||||
$0 =~ m|^(/)?(.*)/| and $ENV{GL_BINDIR} = ( $1 || "$ENV{PWD}/" ) . $2;
|
||||
}
|
||||
use FindBin;
|
||||
|
||||
BEGIN { $ENV{GL_BINDIR} = $FindBin::RealBin; }
|
||||
use lib $ENV{GL_BINDIR};
|
||||
use Gitolite::Rc;
|
||||
use Gitolite::Common;
|
8
t/README
Normal file
8
t/README
Normal file
|
@ -0,0 +1,8 @@
|
|||
WARNING: THE TEST SUITE DELETES STUFF FIRST!
|
||||
|
||||
Testing gitolite3 is now one command after the clone:
|
||||
|
||||
prove
|
||||
|
||||
But because it starts by cleaning the slate, it's best to do it on a spare
|
||||
userid that you are ok to lose data on.
|
|
@ -3,7 +3,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
# this is hardcoded; change it if needed
|
||||
use lib "$ENV{HOME}/bin";
|
||||
use lib "src";
|
||||
use Gitolite::Test;
|
||||
|
||||
# basic tests
|
|
@ -9,4 +9,4 @@ $repo =~ s/\.git$//;
|
|||
my $user = $ENV{G3T_USER} || 'no-such-user';
|
||||
|
||||
$ENV{SSH_ORIGINAL_COMMAND} = "git-receive-pack '$repo'";
|
||||
exec( "$ENV{HOME}/bin/gitolite-shell", $user );
|
||||
exec( "$ENV{GL_BINDIR}/../src/gitolite-shell", $user );
|
||||
|
|
|
@ -9,4 +9,4 @@ $repo =~ s/\.git$//;
|
|||
my $user = $ENV{G3T_USER} || 'no-such-user';
|
||||
|
||||
$ENV{SSH_ORIGINAL_COMMAND} = "git-upload-pack '$repo'";
|
||||
exec( "$ENV{HOME}/bin/gitolite-shell", $user );
|
||||
exec( "$ENV{GL_BINDIR}/../src/gitolite-shell", $user );
|
||||
|
|
7
t/glt
7
t/glt
|
@ -2,6 +2,9 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
BEGIN { $ENV{GL_BINDIR} = $FindBin::RealBin; }
|
||||
|
||||
print STDERR "TRACE: glt(", join( ")(", @ARGV ), ")\n";
|
||||
|
||||
my $cmd = shift or die "need command";
|
||||
|
@ -10,9 +13,9 @@ my $rc;
|
|||
|
||||
$ENV{G3T_USER} = $user;
|
||||
if ( $cmd eq 'push' ) {
|
||||
$rc = system( "git", $cmd, "--receive-pack=$ENV{HOME}/bin/gitolite-receive-pack", @ARGV );
|
||||
$rc = system( "git", $cmd, "--receive-pack=$ENV{GL_BINDIR}/gitolite-receive-pack", @ARGV );
|
||||
} else {
|
||||
$rc = system( "git", $cmd, "--upload-pack=$ENV{HOME}/bin/gitolite-upload-pack", @ARGV );
|
||||
$rc = system( "git", $cmd, "--upload-pack=$ENV{GL_BINDIR}/gitolite-upload-pack", @ARGV );
|
||||
}
|
||||
|
||||
if ( $? == -1 ) {
|
||||
|
|
Loading…
Reference in a new issue