aboutsummaryrefslogtreecommitdiffstats
path: root/mgagit
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mars-attacks.org>2013-06-21 18:46:40 +0200
committerNicolas Vigier <boklm@mars-attacks.org>2013-06-21 18:47:20 +0200
commit26a30df329ca1310a2b54bb50974a3b96af41ce3 (patch)
tree5d7b4619a18e24fe88ccf4a491b13b392023dfbc /mgagit
downloadmgagit-26a30df329ca1310a2b54bb50974a3b96af41ce3.tar
mgagit-26a30df329ca1310a2b54bb50974a3b96af41ce3.tar.gz
mgagit-26a30df329ca1310a2b54bb50974a3b96af41ce3.tar.bz2
mgagit-26a30df329ca1310a2b54bb50974a3b96af41ce3.tar.xz
mgagit-26a30df329ca1310a2b54bb50974a3b96af41ce3.zip
Initial commit
Diffstat (limited to 'mgagit')
-rwxr-xr-xmgagit79
1 files changed, 79 insertions, 0 deletions
diff --git a/mgagit b/mgagit
new file mode 100755
index 0000000..df5e699
--- /dev/null
+++ b/mgagit
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+
+use strict;
+use MGA::Git;
+#use Data::Dump qw/dd/;
+
+my %actions = (
+ glconf => {
+ run => \&glconf,
+ descr => 'Print gitolite configuration',
+ usage => <<END,
+$0 glconf [repo]
+
+Print the gitolite configuration. Optionaly you can add a repository
+name as parameter to display the configuration for this repository only.
+END
+ },
+ glrun => {
+ run => \&glrun,
+ descr => 'Update gitolite configuration',
+ usage => <<END,
+$0 glrun
+
+Update gitolite configuration, and run gitolite if changed.
+END
+ },
+ usage => {
+ run => \&usage,
+ descr => 'Show usage informations for an action',
+ usage => <<END,
+$0 usage [action]
+
+Show action usage
+END
+ },
+);
+
+sub usage {
+ if ($_[1] && $actions{$_[1]}) {
+ print STDERR $actions{$_[1]}->{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);
+ 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::update_gitolite_config(\%r);
+}
+
+if (@ARGV == 0 || !$actions{$ARGV[0]}) {
+ usageexit();
+}
+$actions{$ARGV[0]}->{run}->(@ARGV);
+