From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B54061F54E for ; Tue, 4 Oct 2022 19:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664910761; bh=pWhwDa3p/0XuLAIm/iSqlQTtXuZmC/EK26YuxEO1jYE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=foo3+ifsQBMoKiSoCiyXpWcQLHgGaCgpbK7L9Ie5kI8a3eqrRObuJdg9izg2ghjAr 0i3hjZu45XsvBnzHIehu4wi2rkfKIWbXQ/XwD4K5SDwKyh1x0YsvpqzKP9/e8J7kIU d7e4CU1d0ySfEoNhlpx8on4iYrRcAwN3sHSymlwI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/10] www_stream: use git->pub_urls for coderepo links Date: Tue, 4 Oct 2022 19:12:39 +0000 Message-Id: <20221004191240.1056304-10-e@80x24.org> In-Reply-To: <20221004191240.1056304-1-e@80x24.org> References: <20221004191240.1056304-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This is already used by */$OID/s/, so just reuse existing code and make git->local_nick use the assigned nick from the config file, if there is one. --- lib/PublicInbox/Git.pm | 3 ++- lib/PublicInbox/WwwStream.pm | 17 +++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 2ed3a29b..882a9a4a 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -452,7 +452,8 @@ sub DESTROY { cleanup(@_) } sub local_nick ($) { # don't show full FS path, basename should be OK: - $_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? "$1.git" : undef; + $_[0]->{nick} // ($_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? + "$1.git" : undef); } sub host_prefix_url ($$) { diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 92d243eb..ccac5e8b 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -98,16 +98,13 @@ sub coderepos ($) { my @ret = ('' . 'Code repositories for project(s) associated with this '. $ctx->{ibx}->thing_type . "\n"); - for my $cr_name (@$cr) { - my $urls = $cfg->get_all("coderepo.$cr_name.cgiturl"); - if ($urls) { - for (@$urls) { - my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $pfx.$_; - $u = ascii_html(prurl($ctx->{env}, $u)); - $ret[0] .= qq(\n\t$u); - } - } else { - $ret[0] .= qq[\n\t$cr_name.git (no URL configured)]; + my $objs = $cfg->repo_objs($ctx->{ibx}); + for my $git (@$objs) { + my @urls = $git->pub_urls; + for (@urls) { + my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $pfx.$_; + $u = ascii_html(prurl($ctx->{env}, $u)); + $ret[0] .= qq(\n\t$u); } } @ret; # may be empty, this sub is called as an arg for join()