From 1f34241e5dc94417d49e2c728e0f2ea04ddc39b0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Feb 2017 20:53:42 +0000 Subject: repobrowse: shorten "repo_info" to "-repo" This makes it more consistent with how we use the Inbox objects for the main code. --- lib/PublicInbox/RepoBase.pm | 4 ++-- lib/PublicInbox/RepoGitAtom.pm | 14 +++++++------- lib/PublicInbox/RepoGitBlob.pm | 4 ++-- lib/PublicInbox/RepoGitCommit.pm | 4 ++-- lib/PublicInbox/RepoGitDiff.pm | 2 +- lib/PublicInbox/RepoGitFallback.pm | 2 +- lib/PublicInbox/RepoGitLog.pm | 10 +++++----- lib/PublicInbox/RepoGitPatch.pm | 2 +- lib/PublicInbox/RepoGitPlain.pm | 2 +- lib/PublicInbox/RepoGitSnapshot.pm | 10 +++++----- lib/PublicInbox/RepoGitSummary.pm | 10 +++++----- lib/PublicInbox/RepoGitTag.pm | 12 ++++++------ lib/PublicInbox/RepoGitTree.pm | 4 ++-- lib/PublicInbox/Repobrowse.pm | 14 +++++++------- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/PublicInbox/RepoBase.pm b/lib/PublicInbox/RepoBase.pm index 668e9711..8c5f5c9d 100644 --- a/lib/PublicInbox/RepoBase.pm +++ b/lib/PublicInbox/RepoBase.pm @@ -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) { diff --git a/lib/PublicInbox/RepoGitAtom.pm b/lib/PublicInbox/RepoGitAtom.pm index cf4df11c..531d8b9d 100644 --- a/lib/PublicInbox/RepoGitAtom.pm +++ b/lib/PublicInbox/RepoGitAtom.pm @@ -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(\n) . qq() . qq($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 { diff --git a/lib/PublicInbox/RepoGitBlob.pm b/lib/PublicInbox/RepoGitBlob.pm index f9c28c22..ca8a3c2f 100644 --- a/lib/PublicInbox/RepoGitBlob.pm +++ b/lib/PublicInbox/RepoGitBlob.pm @@ -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; } diff --git a/lib/PublicInbox/RepoGitCommit.pm b/lib/PublicInbox/RepoGitCommit.pm index c1cf06db..21f450ea 100644 --- a/lib/PublicInbox/RepoGitCommit.pm +++ b/lib/PublicInbox/RepoGitCommit.pm @@ -41,7 +41,7 @@ sub commit_header { qq( commit $H (patch)\n) . qq( tree $t); - 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, '--'); diff --git a/lib/PublicInbox/RepoGitDiff.pm b/lib/PublicInbox/RepoGitDiff.pm index ef4717ac..0e79f119 100644 --- a/lib/PublicInbox/RepoGitDiff.pm +++ b/lib/PublicInbox/RepoGitDiff.pm @@ -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}; diff --git a/lib/PublicInbox/RepoGitFallback.pm b/lib/PublicInbox/RepoGitFallback.pm index 5ce469be..8675d0d7 100644 --- a/lib/PublicInbox/RepoGitFallback.pm +++ b/lib/PublicInbox/RepoGitFallback.pm @@ -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); } diff --git a/lib/PublicInbox/RepoGitLog.pm b/lib/PublicInbox/RepoGitLog.pm index 09409edd..b759a5c0 100644 --- a/lib/PublicInbox/RepoGitLog.pm +++ b/lib/PublicInbox/RepoGitLog.pm @@ -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}; diff --git a/lib/PublicInbox/RepoGitPatch.pm b/lib/PublicInbox/RepoGitPatch.pm index d851457c..e1431f39 100644 --- a/lib/PublicInbox/RepoGitPatch.pm +++ b/lib/PublicInbox/RepoGitPatch.pm @@ -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/; diff --git a/lib/PublicInbox/RepoGitPlain.pm b/lib/PublicInbox/RepoGitPlain.pm index 6114a858..79a15be6 100644 --- a/lib/PublicInbox/RepoGitPlain.pm +++ b/lib/PublicInbox/RepoGitPlain.pm @@ -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; diff --git a/lib/PublicInbox/RepoGitSnapshot.pm b/lib/PublicInbox/RepoGitSnapshot.pm index 9ba4c04a..44a6bd59 100644 --- a/lib/PublicInbox/RepoGitSnapshot.pm +++ b/lib/PublicInbox/RepoGitSnapshot.pm @@ -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 }; diff --git a/lib/PublicInbox/RepoGitSummary.pm b/lib/PublicInbox/RepoGitSummary.pm index 0ecef981..76d9c2b9 100644 --- a/lib/PublicInbox/RepoGitSummary.pm +++ b/lib/PublicInbox/RepoGitSummary.pm @@ -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") . ''); my $rel = $req->{relcmd}; @@ -76,7 +76,7 @@ sub for_each_ref { $fh->write('
'); # 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) { diff --git a/lib/PublicInbox/RepoGitTag.pm b/lib/PublicInbox/RepoGitTag.pm index d046f853..6a35f61c 100644 --- a/lib/PublicInbox/RepoGitTag.pm +++ b/lib/PublicInbox/RepoGitTag.pm @@ -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") . '' . join('', map { "" } qw(tag date subject)). ''; @@ -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($label\n); $fh->write($self->html_start($req, - "$repo_info->{repo}: ref: $h") . + "$repo->{repo}: ref: $h") . "\n\n $h (lightweight tag)\nobject $obj_link\n"); } diff --git a/lib/PublicInbox/RepoGitTree.pm b/lib/PublicInbox/RepoGitTree.pm index 840af9ad..716dfe02 100644 --- a/lib/PublicInbox/RepoGitTree.pm +++ b/lib/PublicInbox/RepoGitTree.pm @@ -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); diff --git a/lib/PublicInbox/Repobrowse.pm b/lib/PublicInbox/Repobrowse.pm index 2513a105..7f50a877 100644 --- a/lib/PublicInbox/Repobrowse.pm +++ b/lib/PublicInbox/Repobrowse.pm @@ -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 -- cgit v1.2.3-24-ge0c7
$_