]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwCoderepo.pm
www_coderepo: tree: do not break #n$LINENO
[public-inbox.git] / lib / PublicInbox / WwwCoderepo.pm
index 53126e19b1ef781e2f8bcdbca5efeb0ff41667ba..f9c150c0604a6f6c1b8146b503c9715b5b16c85a 100644 (file)
@@ -18,6 +18,7 @@ use PublicInbox::Hval qw(ascii_html);
 use PublicInbox::ViewDiff qw(uri_escape_path);
 use PublicInbox::RepoSnapshot;
 use PublicInbox::RepoAtom;
+use PublicInbox::RepoTree;
 
 my $EACH_REF = "git for-each-ref --sort=-creatordate --format='%(HEAD)%00".
        join('%00', map { "%($_)" }
@@ -42,13 +43,11 @@ sub prepare_coderepos {
                $k = substr($k, length('publicinbox.'), -length('.coderepo'));
                my $ibx = $pi_cfg->lookup_name($k) // next;
                $pi_cfg->repo_objs($ibx);
-               push @{$self->{-strong}}, $ibx; # strengthen {-ibxs} weakref
        }
        for my $k (grep(/\Aextindex\.(?:.+)\.coderepo\z/, keys %$pi_cfg)) {
                $k = substr($k, length('extindex.'), -length('.coderepo'));
                my $eidx = $pi_cfg->lookup_ei($k) // next;
                $pi_cfg->repo_objs($eidx);
-               push @{$self->{-strong}}, $eidx; # strengthen {-ibxs} weakref
        }
 }
 
@@ -81,14 +80,7 @@ sub summary_finish {
                $tip_html .= ' '.ascii_html($tip).' --';
        }
        print $zfh <<EOM;
-<pre>
-<a
-href='#readme'>about</a> <a
-href='#heads'>heads</a> <a
-href='#tags'>tags</a>
-
-<a
-id=log>\$</a> git log --pretty=format:'%h %s (%cs)%d'$tip_html
+<pre><a id=log>\$</a> git log --pretty=format:'%h %s (%cs)%d'$tip_html
 EOM
        for (@r) {
                my $d; # decorations
@@ -231,9 +223,14 @@ sub srv { # endpoint called by PublicInbox::WWW
        }
        $path_info =~ m!\A/(.+?)/\z! and
                ($ctx->{git} = $cr->{$1}) and return summary($self, $ctx);
-       $path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/\z! and
+       $path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/([^/]+)?\z! and
                        ($ctx->{git} = $cr->{$1}) and
-               return PublicInbox::ViewVCS::show($ctx, $2);
+               return PublicInbox::ViewVCS::show($ctx, $2, $3);
+
+       if ($path_info =~ m!\A/(.+?)/tree/(.*)\z! and
+                       ($ctx->{git} = $cr->{$1})) {
+               return PublicInbox::RepoTree::srv_tree($ctx, $2) // r(404);
+       }
 
        # snapshots:
        if ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and