From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/5] config: support cgit scan-path and scan-hidden-path
Date: Fri, 5 Apr 2019 20:04:25 +0000 [thread overview]
Message-ID: <20190405200429.16973-2-e@80x24.org> (raw)
In-Reply-To: <20190405200429.16973-1-e@80x24.org>
project_list support still needs to be done
And tests need to be written... :<
---
lib/PublicInbox/Config.pm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 9c1c3e2..9f1e57a 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;
--
EW
next prev parent reply other threads:[~2019-04-05 20:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 20:04 [PATCH 0/5] a few more cgit compatibility updates Eric Wong
2019-04-05 20:04 ` Eric Wong [this message]
2019-04-05 20:04 ` [PATCH 2/5] cgit: serve static css, logo, favicon directly Eric Wong
2019-04-05 20:04 ` [PATCH 3/5] config: support more cgit directives for project lists Eric Wong
2019-04-15 6:53 ` [PATCH 6/5] config: fix regression in repo.path => coderepo.dir mapping Eric Wong
2019-04-05 20:04 ` [PATCH 4/5] doc/config: update cgit.cgi scan location Eric Wong
2019-04-05 20:04 ` [PATCH 5/5] viewdiff: document constants Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190405200429.16973-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).