From 3adb3d824864804a357b68dd33f9c2c973742174 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 17 Feb 2017 23:40:37 +0000 Subject: repobrowse: minor style cleanups Avoid using '=>' arrow notation for arrays and array references, it is confusing and more verbose. Additionally, combine "use constant" statements when possible. --- lib/PublicInbox/RepoBase.pm | 2 +- lib/PublicInbox/RepoGitBlob.pm | 4 ++-- lib/PublicInbox/RepoGitCommit.pm | 15 ++++++++------- lib/PublicInbox/RepoGitSummary.pm | 2 +- lib/PublicInbox/Repobrowse.pm | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/RepoBase.pm b/lib/PublicInbox/RepoBase.pm index 8c5f5c9d..9876cf2a 100644 --- a/lib/PublicInbox/RepoBase.pm +++ b/lib/PublicInbox/RepoBase.pm @@ -16,7 +16,7 @@ sub call { my $sub = "call_${vcs}_$cmd"; $self->$sub($req); }; - $@ ? [ 500, ['Content-Type'=>'text/plain'], [] ] : $rv; + $@ ? [ 500, ['Content-Type', 'text/plain'], [] ] : $rv; } sub mime_load { diff --git a/lib/PublicInbox/RepoGitBlob.pm b/lib/PublicInbox/RepoGitBlob.pm index b535b0ad..84f48c65 100644 --- a/lib/PublicInbox/RepoGitBlob.pm +++ b/lib/PublicInbox/RepoGitBlob.pm @@ -56,8 +56,8 @@ sub git_blob_stream_response { my ($res) = @_; my $to_read = 8192; eval { - my $fh = $res->([ 200, ['Content-Length' => $size, - 'Content-Type' => $type]]); + my $fh = $res->([ 200, ['Content-Length', $size, + 'Content-Type', $type]]); $fh->write($buf) if defined $buf; while ($left > 0) { $to_read = $left if $to_read > $left; diff --git a/lib/PublicInbox/RepoGitCommit.pm b/lib/PublicInbox/RepoGitCommit.pm index 1a10b13c..2d4234cc 100644 --- a/lib/PublicInbox/RepoGitCommit.pm +++ b/lib/PublicInbox/RepoGitCommit.pm @@ -20,12 +20,13 @@ use PublicInbox::RepoGit qw(git_unquote git_commit_title); use PublicInbox::RepoGitDiffCommon; use PublicInbox::Qspawn; -use constant GIT_FMT => '--pretty=format:'.join('%n', - '%H', '%h', '%s', '%an <%ae>', '%ai', '%cn <%ce>', '%ci', - '%t', '%p', '%D', '%b%x00'); - -use constant CC_EMPTY => " This is a merge, and the combined diff is empty.\n"; -use constant CC_MERGE => " This is a merge, showing combined diff:\n\n"; +use constant { + GIT_FMT => '--pretty=format:'.join('%n', + '%H', '%h', '%s', '%an <%ae>', '%ai', '%cn <%ce>', '%ci', + '%t', '%p', '%D', '%b%x00'), + CC_EMPTY => " This is a merge, and the combined diff is empty.\n", + CC_MERGE => " This is a merge, showing combined diff:\n\n" +}; sub commit_header { my ($self, $req) = @_; @@ -155,7 +156,7 @@ sub git_commit_404 { $x .= "$try the latest commit in HEAD\n"; $x .= ''; - [404, ['Content-Type'=>'text/html'], [ $x ]]; + [404, ['Content-Type', 'text/html'], [ $x ]]; } # FIXME: horrifically expensive... diff --git a/lib/PublicInbox/RepoGitSummary.pm b/lib/PublicInbox/RepoGitSummary.pm index 38fce1f5..5eb8087d 100644 --- a/lib/PublicInbox/RepoGitSummary.pm +++ b/lib/PublicInbox/RepoGitSummary.pm @@ -32,7 +32,7 @@ sub for_each_ref { 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']]); + $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->{repo}: overview") . diff --git a/lib/PublicInbox/Repobrowse.pm b/lib/PublicInbox/Repobrowse.pm index 86778514..6fc060ae 100644 --- a/lib/PublicInbox/Repobrowse.pm +++ b/lib/PublicInbox/Repobrowse.pm @@ -73,7 +73,7 @@ sub no_tslash { } my $url = $base . $uri . $qs; [ 301, - [ Location => $url, 'Content-Type' => 'text/plain' ], + [ 'Location', $url, 'Content-Type', 'text/plain' ], [ "Redirecting to $url\n" ] ] } -- cgit v1.2.3-24-ge0c7