#!/usr/bin/perl -w use strict; use MGA::Git; use YAML; #use Data::Dump qw/dd/; my %actions = ( glconf => { run => \&glconf, descr => 'Print gitolite configuration', usage => < { run => \&glrun, descr => 'Update gitolite configuration', usage => < { run => \&usage, descr => 'Show usage informations for an action', usage => < { run => \&showconf, descr => 'Show YAML mgagit configuration', usage => <{usage}; } else { print STDERR "$0 [action] [options]\n"; print STDERR "$0 usage [action]\n\n"; print STDERR "Available actions:\n"; print STDERR map { " - $_ : $actions{$_}->{descr}\n" } keys %actions; } } sub usageexit { usage(@_); exit 1; } sub glconf { usageexit('usage', $_[0]) unless @_ <= 2; my %r; MGA::Git::load_gitrepos(\%r); MGA::Git::load_groups(\%r) if @_ == 1; MGA::Git::load_users(\%r); if (my $repo = $_[1]) { if (!$r{repos}{$repo}) { print STDERR "Cannot find repository $repo\n"; exit 1; } print MGA::Git::gitolite_repo_config(\%r, $repo); } else { print MGA::Git::gitolite_config(\%r), "\n"; } } sub glrun { usageexit('usage', $_[0]) unless @_ == 1; my %r; MGA::Git::load_gitrepos(\%r); MGA::Git::load_groups(\%r); MGA::Git::load_users(\%r); MGA::Git::dumpdb(\%r); MGA::Git::update_gitolite_keydir(\%r); MGA::Git::update_gitolite_config(\%r); MGA::Git::run_gitolite(\%r); } sub showconf { my %r; MGA::Git::load_gitrepos(\%r); print YAML::Dump(\%r); } if (@ARGV == 0 || !$actions{$ARGV[0]}) { usageexit(); } $actions{$ARGV[0]}->{run}->(@ARGV);