]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: rename "tree" endpoint to "src"
authorEric Wong <e@80x24.org>
Thu, 2 Mar 2017 23:39:49 +0000 (23:39 +0000)
committerEric Wong <e@80x24.org>
Thu, 2 Mar 2017 23:39:49 +0000 (23:39 +0000)
This is shorter, and makes more sense as the endpoint
displays both tree listings and actual blob sources.
This will also make rewriting existing URLs from cgit
installations easier.

MANIFEST
lib/PublicInbox/RepoGitCommit.pm
lib/PublicInbox/RepoGitDiffCommon.pm
lib/PublicInbox/RepoGitSrc.pm [moved from lib/PublicInbox/RepoGitTree.pm with 97% similarity]
lib/PublicInbox/RepoGitSummary.pm
lib/PublicInbox/Repobrowse.pm
t/repobrowse_git_src.t [moved from t/repobrowse_git_tree.t with 88% similarity]

index 495a63e6e24d84adb495761fd04aa66180c5ca0c..d49b45ceaf3d37d524303295a7de497aea2b3d57 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -97,9 +97,9 @@ lib/PublicInbox/RepoGitRaw.pm
 lib/PublicInbox/RepoGitSearch.pm
 lib/PublicInbox/RepoGitSearchIdx.pm
 lib/PublicInbox/RepoGitSnapshot.pm
+lib/PublicInbox/RepoGitSrc.pm
 lib/PublicInbox/RepoGitSummary.pm
 lib/PublicInbox/RepoGitTag.pm
-lib/PublicInbox/RepoGitTree.pm
 lib/PublicInbox/RepoRoot.pm
 lib/PublicInbox/Repobrowse.pm
 lib/PublicInbox/SaPlugin/ListMirror.pm
@@ -197,7 +197,7 @@ t/repobrowse_git_httpd.t
 t/repobrowse_git_log.t
 t/repobrowse_git_raw.t
 t/repobrowse_git_snapshot.t
-t/repobrowse_git_tree.t
+t/repobrowse_git_src.t
 t/search.t
 t/spamcheck_spamc.t
 t/spawn.t
index 34f7acc3b54cf4a17d2238f850b348c5ac9dbd5c..8add3006a1fbbb137d606228ccf6fd17692e718a 100644 (file)
@@ -40,7 +40,7 @@ sub commit_header {
        my $rel = $req->{relcmd};
        my $x = $self->html_start($req, $s) . "\n" .
                qq(   commit $H (<a\nhref="${rel}patch/$H">patch</a>)\n) .
-               qq(     tree <a\nrel=nofollow\nhref="${rel}tree/$H">$t</a>);
+               qq(     tree <a\nrel=nofollow\nhref="${rel}src/$H">$t</a>);
 
        my $git = $req->{-repo}->{git};
        # extra show path information, if any
@@ -55,7 +55,7 @@ sub commit_header {
                        my $e = PublicInbox::Hval->utf8($_, join('/', @t));
                        $ep = $e->as_path;
                        my $eh = $e->as_html;
-                       $ep = "${rel}tree/$ep/$H";
+                       $ep = "${rel}src/$ep/$H";
                        qq(<a\nrel=nofollow\nhref="$ep">$eh</a>);
                } @$extra);
                $path = "/$ep";
@@ -185,7 +185,7 @@ sub show_unchanged {
                $p = $p->as_path;
                $fn = utf8_html($fn);
                $$dst .= qq(\t<a\nrel=nofollow);
-               $$dst .= qq(\nid="$anchor"\nhref="${rel}tree/$p">);
+               $$dst .= qq(\nid="$anchor"\nhref="${rel}src/$p">);
                $$dst .= "$fn</a>\n";
        }
 }
index 46e243ed0277b7a757196e1987d76e7d8776c2a3..b60a5fbce1b70f181eccd096a2c8ec18fbe56505 100644 (file)
@@ -68,7 +68,7 @@ sub git_diff_ab_hunk ($$$$) {
                $na = defined $na ? "#n$na" : '';
                my $p = $req->{p}->[0];
                $rv .= qq(<a\nrel=nofollow);
-               $rv .= qq(\nhref="${rel}tree/$p/$req->{path_a}$na">);
+               $rv .= qq(\nhref="${rel}src/$p/$req->{path_a}$na">);
                $rv .= "$ca</a>";
        }
        $rv .= ' ';
@@ -77,7 +77,7 @@ sub git_diff_ab_hunk ($$$$) {
        } else {
                $nb = defined $nb ? "#n$nb" : '';
                $rv .= qq(<a\nrel=nofollow);
-               $rv .= qq(\nhref="${rel}tree/$req->{-tip}/$req->{path_b}$nb">);
+               $rv .= qq(\nhref="${rel}src/$req->{-tip}/$req->{path_b}$nb">);
                $rv .= "$cb</a>";
        }
        $rv . ' @@' . utf8_html($ctx);
@@ -121,14 +121,14 @@ sub git_diff_cc_hunk {
                }
        }
 
-       # we can use the normal 'tree' endpoint for the result
+       # we can use the normal 'src' endpoint for the result
        my ($n) = ($last =~ /\A\+(\d+)/); # line number
        if ($n == 0) { # deleted file (does this happen with --cc?)
                $rv .= " $last";
        } else {
                my $H = $req->{H};
                $rv .= qq( <a\nrel=nofollow);
-               $rv .= qq(\nhref="${rel}tree/$H/$path#n$n">$last</a>);
+               $rv .= qq(\nhref="${rel}src/$H/$path#n$n">$last</a>);
        }
        $rv .= " $at" . utf8_html($ctx);
 }
similarity index 97%
rename from lib/PublicInbox/RepoGitTree.pm
rename to lib/PublicInbox/RepoGitSrc.pm
index e8c34a6995f6c1e7971d4af78b84009b0ee0b385..1546830f0acaf8eff8f0cdc9925e6cc9c7f93e8f 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoGitTree;
+package PublicInbox::RepoGitSrc;
 use strict;
 use warnings;
 use base qw(PublicInbox::RepoBase);
@@ -19,7 +19,7 @@ my $BINARY_MSG = "Binary file, save using the 'raw' link above";
 my $MAX_ASYNC = 65536; # same as pipe size on Linux
 my $BIN_DETECT = 8000; # same as git (buffer_is_binary in git.git)
 
-sub call_git_tree {
+sub call_git_src {
        my ($self, $req) = @_;
        my $repo = $req->{-repo};
        my $git = $repo->{git};
@@ -63,7 +63,7 @@ sub cur_path {
        my $rel = $req->{relcmd};
        # avoid relative paths, here, we don't want to propagate
        # trailing-slash URLs although we tolerate them
-       $s = "<a\nhref=\"${rel}tree/$tip\">root</a>/";
+       $s = "<a\nhref=\"${rel}src/$tip\">root</a>/";
        my $cur = pop @ex;
        my @t;
        $s .= join('/', (map {
@@ -71,7 +71,7 @@ sub cur_path {
                my $e = PublicInbox::Hval->utf8($_, join('/', @t));
                my $ep = $e->as_path;
                my $eh = $e->as_html;
-               "<a\nhref=\"${rel}tree/$tip/$ep\">$eh</a>";
+               "<a\nhref=\"${rel}src/$tip/$ep\">$eh</a>";
        } @ex), '<b>'.utf8_html($cur).'</b>');
 }
 
@@ -230,7 +230,7 @@ sub git_tree_show {
        } elsif (defined(my $tip = $req->{tip})) {
                $pfx = $tip;
        } else {
-               $pfx = 'tree/' . $req->{-repo}->tip;
+               $pfx = 'src/' . $req->{-repo}->tip;
        }
        $req->{tpfx} = $pfx;
        my $env = $req->{env};
index 5eb8087de36657097d2f083372cfd2a30118bec6..96ae9be913dea768de5093ab018cad0659aebf9f 100644 (file)
@@ -84,14 +84,14 @@ sub readme_path_links {
        my ($req, $rel, $readme) = @_;
        my @path = split(m!/+!, $readme);
        my $tip = $req->{-repo}->tip;
-       my $s = "tree <a\nhref=\"${rel}tree/$tip\">root</a>/";
+       my $s = "tree <a\nhref=\"${rel}src/$tip\">root</a>/";
        my @t;
        $s .= join('/', (map {
                push @t, $_;
                my $e = PublicInbox::Hval->utf8($_, join('/', @t));
                my $ep = $e->as_path;
                my $eh = $e->as_html;
-               $e = "<a\nhref=\"${rel}tree/$tip/$ep\">$eh</a>";
+               $e = "<a\nhref=\"${rel}src/$tip/$ep\">$eh</a>";
                # bold the last one
                scalar(@t) == scalar(@path) ? "<b>$e</b>" : $e;
        } @path));
index aad0e8ba200dcf5bfd4eff55706b7011eae7fb8a..5ef9e59a71eb49e964563131a1b0880d26cb819c 100644 (file)
@@ -22,7 +22,7 @@ use strict;
 use warnings;
 use PublicInbox::RepoConfig;
 
-my %CMD = map { lc($_) => $_ } qw(Log Commit Tree Patch Blob Raw Tag Atom
+my %CMD = map { lc($_) => $_ } qw(Log Commit Src Patch Blob Raw Tag Atom
        Diff Snapshot);
 my %VCS = (git => 'Git');
 my %LOADED;
@@ -93,7 +93,7 @@ sub call {
        }
 
        # URL syntax: / repo [ / cmd [ / head [ / path ] ] ]
-       # cmd: log | commit | diff | tree | view | blob | snapshot
+       # cmd: log | commit | diff | src | view | blob | snapshot
        # repo and path (@extra) may both contain '/'
        my $path_info = $env->{PATH_INFO};
        my (undef, $repo_path, @extra) = split(m{/+}, $path_info, -1);
similarity index 88%
rename from t/repobrowse_git_tree.t
rename to t/repobrowse_git_src.t
index d91cfdc998c1788212f5a5eec97471fba7a33014..4d16eac4f0a23ae54f96c29d33f564fce2a0ba47 100644 (file)
@@ -7,7 +7,7 @@ my $test = require './t/repobrowse_common_git.perl';
 test_psgi($test->{app}, sub {
        my ($cb) = @_;
 
-       my $req = 'http://example.com/test.git/tree/HEAD/dir';
+       my $req = 'http://example.com/test.git/src/HEAD/dir';
        my $res = $cb->(GET($req));
        is(200, $res->code, 'got 200 response from dir');
        my $noslash_body = dechunk($res);
@@ -19,7 +19,7 @@ test_psgi($test->{app}, sub {
        is(301, $r2->code, 'got 301 response from dir with slash');
        is($req, $r2->header('Location'), 'redirected w/o slash');
 
-       $req = 'http://example.com/test.git/tree/master/foo.txt';
+       $req = 'http://example.com/test.git/src/master/foo.txt';
        my $blob = $cb->(GET($req));
        is($blob->header('Content-Type'), 'text/html; charset=UTF-8',
                'got text/html blob');