diff options
author | Eric Wong <e@80x24.org> | 2019-04-05 20:04:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-04-15 06:20:33 +0000 |
commit | 8efc7b62fc3e3bd94d0196fc1942ca9572a481cc (patch) | |
tree | d80d2c790e9a79f1c9ba635eddda0171fe1a55d1 | |
parent | 96d4a98d1a28ec64b5abd8289ddd4177ff87ad7e (diff) | |
download | public-inbox-8efc7b62fc3e3bd94d0196fc1942ca9572a481cc.tar.gz |
project_list support still needs to be done And tests need to be written... :<
-rw-r--r-- | lib/PublicInbox/Config.pm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 9c1c3e2c..9f1e57ac 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -208,6 +208,30 @@ sub cgit_repo_merge ($$) { $self->{"coderepo.$nick.cgiturl"} ||= $nick; } +sub is_git_dir ($) { + my ($git_dir) = @_; + -d "$git_dir/objects" && -f "$git_dir/HEAD"; +} + +sub scan_path_coderepo { + my ($self, $base, $path) = @_; + opendir my $dh, $path or return; + while (defined(my $dn = readdir $dh)) { + next if $dn eq '.' || $dn eq '..'; + if (index($dn, '.') == 0 && !$self->{-cgit_scan_hidden_path}) { + next; + } + my $nick = $base eq '' ? $dn : "$base/$dn"; + my $git_dir = "$path/$dn"; + if (is_git_dir($git_dir)) { + my $repo = { url => $nick, path => $git_dir }; + cgit_repo_merge($self, $repo); + } elsif (-d $git_dir) { + scan_path_coderepo($self, $nick, $git_dir); + } + } +} + sub parse_cgitrc { my ($self, $cgitrc, $nesting) = @_; @@ -235,6 +259,10 @@ sub parse_cgitrc { } } elsif (m!\Ainclude=(.+)\z!) { parse_cgitrc($self, $1, $nesting + 1); + } elsif (m!\Ascan-hidden-path=(\d+)\z!) { + $self->{-cgit_scan_hidden_path} = $1; + } elsif (m!\Ascan-path=(.+)\z!) { + scan_path_coderepo($self, '', $1); } } cgit_repo_merge($self, $repo) if $repo; |