]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: shorten "repo_info" to "-repo"
authorEric Wong <e@80x24.org>
Thu, 16 Feb 2017 20:53:42 +0000 (20:53 +0000)
committerEric Wong <e@80x24.org>
Thu, 16 Feb 2017 20:53:42 +0000 (20:53 +0000)
This makes it more consistent with how we use the Inbox
objects for the main code.

14 files changed:
lib/PublicInbox/RepoBase.pm
lib/PublicInbox/RepoGitAtom.pm
lib/PublicInbox/RepoGitBlob.pm
lib/PublicInbox/RepoGitCommit.pm
lib/PublicInbox/RepoGitDiff.pm
lib/PublicInbox/RepoGitFallback.pm
lib/PublicInbox/RepoGitLog.pm
lib/PublicInbox/RepoGitPatch.pm
lib/PublicInbox/RepoGitPlain.pm
lib/PublicInbox/RepoGitSnapshot.pm
lib/PublicInbox/RepoGitSummary.pm
lib/PublicInbox/RepoGitTag.pm
lib/PublicInbox/RepoGitTree.pm
lib/PublicInbox/Repobrowse.pm

index 668e97116b7de9bf2832ca52c443ccbc08303c30..8c5f5c9d22b268843beab7a58db80bf6504c4d00 100644 (file)
@@ -10,7 +10,7 @@ sub new { bless {}, shift }
 
 sub call {
        my ($self, $cmd, $req) = @_;
-       my $vcs = $req->{repo_info}->{vcs};
+       my $vcs = $req->{-repo}->{vcs};
        my $rv = eval {
                no strict 'refs';
                my $sub = "call_${vcs}_$cmd";
@@ -58,7 +58,7 @@ sub mime_type {
 # starts an HTML page for Repobrowse in a consistent way
 sub html_start {
        my ($self, $req, $title_html, $opts) = @_;
-       my $desc = $req->{repo_info}->desc_html;
+       my $desc = $req->{-repo}->desc_html;
        my $meta = '';
 
        if ($opts) {
index cf4df11cd6b6226997ab854f96110b0207490073..531d8b9dd233bd12625dea044f704f0ce54b9a15 100644 (file)
@@ -65,12 +65,12 @@ sub git_atom_sed ($$) {
        my $buf = '';
        my $state = 0;
        my $rel = $req->{relcmd};
-       my $repo_info = $req->{repo_info};
-       my $title = join('/', $repo_info->{repo}, @{$req->{extra}});
+       my $repo = $req->{-repo};
+       my $title = join('/', $repo->{repo}, @{$req->{extra}});
        $title = utf8_html("$title, $req->{-tip}");
        my $url = repo_root_url($self, $req);
        my $hdr = {};
-       my $subtitle = $repo_info->desc_html;
+       my $subtitle = $repo->desc_html;
        $req->{axml} = qq(<?xml version="1.0"?>\n) .
                qq(<feed\nxmlns="http://www.w3.org/2005/Atom">) .
                qq(<title>$title</title>) .
@@ -122,7 +122,7 @@ sub git_atom_cb {
                my ($r) = @_;
                my $env = $req->{env};
                if (!defined $r) {
-                       my $git = $req->{repo_info}->{git};
+                       my $git = $req->{-repo}->{git};
                        return [ 400, [ 'Content-Type', 'text/plain' ],
                                [ $git->err ] ];
                }
@@ -133,12 +133,12 @@ sub git_atom_cb {
 
 sub call_git_atom {
        my ($self, $req) = @_;
-       my $repo_info = $req->{repo_info};
-       my $max = $repo_info->{max_commit_count} || 10;
+       my $repo = $req->{-repo};
+       my $max = $repo->{max_commit_count} || 10;
        $max = int($max);
        $max = 50 if $max == 0;
 
-       my $git = $repo_info->{git};
+       my $git = $repo->{git};
        my $env = $req->{env};
        my $tip = $req->{-tip};
        my $read_log = sub {
index f9c28c221ac273204344fa05f0b98cbfd0488533..ca8a3c2f5bd5cbd9c1499565d8f0b6795e1dba15 100644 (file)
@@ -11,7 +11,7 @@ our @EXPORT = qw(git_blob_mime_type git_blob_stream_response);
 
 sub call_git_blob {
        my ($self, $req) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $id = $req->{-tip} . ':' . $req->{expath};
 
        my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
@@ -39,7 +39,7 @@ sub git_blob_mime_type {
        $to_read = $$left if $to_read > $$left;
        my $r = read($cat, $$buf, $to_read);
        if (!defined $r || $r <= 0) {
-               my $git = $req->{repo_info}->{git};
+               my $git = $req->{-repo}->{git};
                $git->cat_file_finish($$left);
                return;
        }
index c1cf06db1c2eb13dda5812cf49e42ea0477151d6..21f450ea7beca779758e9dfa83df50d42a73fcb7 100644 (file)
@@ -41,7 +41,7 @@ sub commit_header {
                qq(   commit $H (<a\nhref="${rel}patch/$h">patch</a>)\n) .
                qq(     tree <a\nrel=nofollow\nhref="${rel}tree/$h">$t</a>);
 
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        # extra show path information, if any
        my $extra = $req->{extra};
        my $path = '';
@@ -125,7 +125,7 @@ sub call_git_commit { # RepoBase calls this
                return $self->r(301, $req, "$relup#".to_attr($expath));
        }
 
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(show -z --numstat -p --encoding=UTF-8
                        --no-notes --no-color -c),
                        $git->abbrev, GIT_FMT, $tip, '--');
index ef4717ac5d40f9956bfdb1396a326429a0766dea..0e79f119c185480fe940d2ff2315010fcab4d65a 100644 (file)
@@ -36,7 +36,7 @@ sub call_git_diff {
        my ($self, $req) = @_;
        my ($id, $id2) = split(/\.\./, $req->{h});
        my $env = $req->{env};
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(diff-tree -z --numstat -p --encoding=UTF-8
                                --no-color -M -B -D -r), $id2, $id, '--');
        my $expath = $req->{expath};
index 5ce469be21880433d2d722127a42cc42fe293051..8675d0d7d0fad981c93fe2a9a3e69607298c03d5 100644 (file)
@@ -14,7 +14,7 @@ sub call {
        my ($self, undef, $req) = @_;
        my $expath = $req->{expath};
        return if index($expath, '..') >= 0; # prevent path traversal
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        PublicInbox::GitHTTPBackend::serve($req->{env}, $git, $expath);
 }
 
index 09409eddab17485fd3ed93637630eb3f47f4c73c..b759a5c080aad2a506df5e2602a2f618bb9b4a55 100644 (file)
@@ -55,7 +55,7 @@ sub git_log_sed_end ($$) {
        my $m = '';
        my $np = 0;
        my $seen = $req->{seen};
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $lpfx = $req->{lpfx};
        foreach my $p (@{$req->{parents}}) {
                next if $seen->{$p};
@@ -121,18 +121,18 @@ sub git_log_sed ($$) {
 
 sub call_git_log {
        my ($self, $req) = @_;
-       my $repo_info = $req->{repo_info};
-       my $max = $repo_info->{max_commit_count} || 50;
+       my $repo = $req->{-repo};
+       my $max = $repo->{max_commit_count} || 50;
        my $h = $req->{h};
        $max = int($max);
        $max = 50 if $max == 0;
        my $env = $req->{env};
-       my $git = $repo_info->{git};
+       my $git = $repo->{git};
        my $cmd = $git->cmd(qw(log --no-notes --no-color --abbrev-commit),
                                $git->abbrev, $LOG_FMT, "-$max",
                                $req->{-tip}, '--');
        my $rdr = { 2 => $git->err_begin };
-       my $title = "log: $repo_info->{repo}";
+       my $title = "log: $repo->{repo}";
        if (defined $h) {
                $title .= ' ('. utf8_html($h). ')';
                $req->{lpfx} = $req->{relcmd};
index d851457c3e676bc18deb137f02c59cd2aa347301..e1431f39a5f7412f348851e63551145883d1cbb9 100644 (file)
@@ -15,7 +15,7 @@ my $sig = '--signature=git '.join(' ', @CMD);
 
 sub call_git_patch {
        my ($self, $req) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $env = $req->{env};
        my $tip = $req->{-tip};
        $tip =~ /\A[\w-]+([~\^][~\^\d])*\z/;
index 6114a8584ffd0dfff6e48c6afbd8b8dec51e5fc4..79a15be6422faa151c6328bfcc52d52c4fa1b7f7 100644 (file)
@@ -10,7 +10,7 @@ use PublicInbox::Qspawn;
 
 sub call_git_plain {
        my ($self, $req) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $id = $req->{-tip} . ':' . $req->{expath};
        my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
        return unless defined $cat;
index 9ba4c04a0fded372ab4bfc98510a0f7f7abbd417..44a6bd596906b64d894a95d2cbbae31175b4bc66 100644 (file)
@@ -45,24 +45,24 @@ sub call_git_snapshot ($$) { # invoked by PublicInbox::RepoBase::call
        return $self->r(404) unless ($ref =~ s/\.($SUFFIX)\z//o);
        my $fmt = $1;
        my $env = $req->{env};
-       my $repo_info = $req->{repo_info};
+       my $repo = $req->{-repo};
 
        # support disabling certain snapshots types entirely to twart
        # URL guessing since it could burn server resources.
-       return $self->r(404) if $repo_info->{snapshots_disabled}->{$fmt};
+       return $self->r(404) if $repo->{snapshots_disabled}->{$fmt};
 
        # strip optional basename (may not exist)
-       $ref =~ s/$repo_info->{snapshot_re}//;
+       $ref =~ s/$repo->{snapshot_re}//;
 
        # don't allow option/command injection, git refs do not start with '-'
        return $self->r(404) if $ref =~ /\A-/;
 
-       my $git = $repo_info->{git};
+       my $git = $repo->{git};
        my $tree = '';
        my $last_cb = sub {
                delete $env->{'repobrowse.tree_cb'};
                delete $env->{'qspawn.quiet'};
-               my $pfx = "$repo_info->{snapshot_pfx}-$ref/";
+               my $pfx = "$repo->{snapshot_pfx}-$ref/";
                my $cmd = $git->cmd('archive',
                                "--prefix=$pfx", "--format=$fmt", $tree);
                my $rdr = { 2 => $git->err_begin };
index 0ecef981872a3bc5c070b4e06649dfff71d20c91..76d9c2b9fe9f19a57f962c2a465551ddf374d638 100644 (file)
@@ -11,7 +11,7 @@ use PublicInbox::Qspawn;
 
 sub call_git_summary {
        my ($self, $req) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $env = $req->{env};
 
        # n.b. we would use %(HEAD) in for-each-ref --format if we could
@@ -36,15 +36,15 @@ sub for_each_ref {
        my ($self, $req, $res, $head_ref) = @_;
        my $count = 10; # TODO: configurable
        my $fh;
-       my $repo_info = $req->{repo_info};
-       my $git = $repo_info->{git};
+       my $repo = $req->{-repo};
+       my $git = $repo->{git};
        my $refs = $git->popen(qw(for-each-ref --sort=-creatordate),
                                EACH_REF_FMT, "--count=$count",
                                qw(refs/heads/ refs/tags/));
        $fh = $res->([200, ['Content-Type'=>'text/html; charset=UTF-8']]);
        # ref names are unpredictable in length and requires tables :<
        $fh->write($self->html_start($req,
-                               "$repo_info->{repo}: overview") .
+                               "$repo->{repo}: overview") .
                        '</pre><table>');
 
        my $rel = $req->{relcmd};
@@ -76,7 +76,7 @@ sub for_each_ref {
        $fh->write('</table>');
 
        # some people will use README.md or even README.sh here...
-       my $readme = $repo_info->{readme};
+       my $readme = $repo->{readme};
        defined $readme or $readme = [ 'README', 'README.md' ];
        $readme = [ $readme ] if (ref($readme) ne 'ARRAY');
        foreach my $r (@$readme) {
index d046f8535f5d51186343c7075d1146bcce7757ed..6a35f61c527a21ccbb88b9dd4aa9a0c7bbe32a5f 100644 (file)
@@ -76,7 +76,7 @@ sub git_show_tag_as_tag {
 
 sub git_tag_show {
        my ($self, $req, $h, $res) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $fh;
        my $hdr = ['Content-Type', 'text/html; charset=UTF-8'];
 
@@ -114,10 +114,10 @@ sub invalid_tag_start {
 
 sub git_each_tag_sed ($$) {
        my ($self, $req) = @_;
-       my $repo_info = $req->{repo_info};
+       my $repo = $req->{-repo};
        my $buf = '';
        my $nr = 0;
-       $req->{thtml} = $self->html_start($req, "$repo_info->{repo}: tag list") .
+       $req->{thtml} = $self->html_start($req, "$repo->{repo}: tag list") .
                '</pre><table><tr>' .
                join('', map { "<th><tt>$_</tt></th>" } qw(tag date subject)).
                '</tr>';
@@ -156,7 +156,7 @@ sub git_each_tag_sed ($$) {
 
 sub git_tag_list {
        my ($self, $req) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
 
        # TODO: use Xapian so we can more easily handle offsets/limits
        # for pagination instead of limiting
@@ -183,7 +183,7 @@ sub git_tag_list {
 
 sub unknown_tag_type {
        my ($self, $fh, $req, $h, $type, $hex) = @_;
-       my $repo_info = $req->{repo_info};
+       my $repo = $req->{-repo};
        $h = $h->as_html;
        my $rel = $req->{relcmd};
        my $label = "$type $hex";
@@ -191,7 +191,7 @@ sub unknown_tag_type {
        my $obj_link = qq(<a\nhref="$rel$cmd/$hex">$label</a>\n);
 
        $fh->write($self->html_start($req,
-                               "$repo_info->{repo}: ref: $h") .
+                               "$repo->{repo}: ref: $h") .
                "\n\n       <b>$h</b> (lightweight tag)\nobject $obj_link\n");
 }
 
index 840af9adf03c664813e719bab033b1f1eb076b9e..716dfe029c94734d95f46c95d89ee64da28f11a9 100644 (file)
@@ -20,7 +20,7 @@ my $BINARY_MSG = "Binary file, save using the 'raw' link above";
 sub call_git_tree {
        my ($self, $req) = @_;
        my @extra = @{$req->{extra}};
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $obj = "$req->{-tip}:$req->{expath}";
        my ($hex, $type, $size) = $git->check($obj);
 
@@ -181,7 +181,7 @@ sub git_tree_sed ($) {
 
 sub git_tree_show {
        my ($req, $hex) = @_;
-       my $git = $req->{repo_info}->{git};
+       my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(ls-tree -l -z), $git->abbrev, $hex);
        my $rdr = { 2 => $git->err_begin };
        my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
index 2513a105805d5d62aeb3aea3cc867828e639889f..7f50a87708f2e3da9e3d07db67466093b7e7bf1a 100644 (file)
@@ -98,22 +98,22 @@ sub call {
        return $self->root_index($self) unless length($repo_path);
 
        my $rconfig = $self->{rconfig}; # RepoConfig
-       my $repo_info;
-       until ($repo_info = $rconfig->lookup($repo_path)) {
+       my $repo;
+       until ($repo = $rconfig->lookup($repo_path)) {
                my $p = shift @extra or last;
                $repo_path .= "/$p";
        }
-       return r404() unless $repo_info;
+       return r404() unless $repo;
 
        my $req = {
-               repo_info => $repo_info,
+               -repo => $repo,
                extra => \@extra, # path
                rconfig => $rconfig,
                env => $env,
        };
        my $tslash = 0;
        my $cmd = shift @extra;
-       my $vcs_lc = $repo_info->{vcs};
+       my $vcs_lc = $repo->{vcs};
        my $vcs = $VCS{$vcs_lc} or return r404();
        my $mod;
        my $h;
@@ -148,8 +148,8 @@ sub call {
        $mod = load_once("PublicInbox::Repo$vcs$mod");
        $vcs = load_once("PublicInbox::$vcs");
 
-       # $repo_info->{git} ||= PublicInbox::Git->new(...)
-       $repo_info->{$vcs_lc} ||= $vcs->new($repo_info->{path});
+       # $repo->{git} ||= PublicInbox::Git->new(...)
+       $repo->{$vcs_lc} ||= $vcs->new($repo->{path});
 
        $req->{expath} = join('/', @extra);
        my $rv = eval { $mod->new->call($cmd, $req) }; # RepoBase::call