From e9e6a950e782419853b4a3b2593445eb6c85de03 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Mon, 24 Jun 2013 15:22:15 +0200 Subject: Allow defining repos directly in main config file --- NEWS | 2 ++ lib/MGA/Git.pm | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 6f91e95..c7bc75b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- allow defining repos directly in main config file + Version 0.1 - first version diff --git a/lib/MGA/Git.pm b/lib/MGA/Git.pm index b964c2b..396e319 100644 --- a/lib/MGA/Git.pm +++ b/lib/MGA/Git.pm @@ -39,8 +39,15 @@ sub load_gitrepos_dir { sub load_gitrepos { my ($r) = @_; $r->{repos} = {}; - foreach my $include (@{$config->{repos_config}}) { - load_gitrepos_dir($r->{repos}, $include); + foreach my $repodef (@{$config->{repos_config}}) { + load_gitrepos_dir($r->{repos}, $repodef) if $repodef->{include_dir}; + foreach my $repo ($repodef->{repos} ? @{$repodef->{repos}} : ()) { + my $name = "$repodef->{prefix}/$repo->{name}"; + $r->{repos}{$name} = $repo; + my %infos = %$repodef; + delete $infos{repos}; + @{$r->{repos}{$name}}{keys %infos} = values %infos; + } } } -- cgit v1.2.1