user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 6/6] www: use autodie in more coderepo places
  2024-01-09 11:39  6% [PATCH 0/6] WWW updates Eric Wong
@ 2024-01-09 11:39  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2024-01-09 11:39 UTC (permalink / raw)
  To: meta

This cuts down on code somewhat (before I add more :x)
---
 lib/PublicInbox/ViewVCS.pm     | 11 ++++-------
 lib/PublicInbox/WwwCoderepo.pm |  5 +++--
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index be062f36..3d835289 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -28,6 +28,7 @@ use PublicInbox::Eml;
 use Text::Wrap qw(wrap);
 use PublicInbox::Hval qw(ascii_html to_filename prurl utf8_maybe);
 use POSIX qw(strftime);
+use autodie qw(open);
 my $hl = eval {
 	require PublicInbox::HlMod;
 	PublicInbox::HlMod->new;
@@ -154,8 +155,7 @@ sub show_commit_start { # ->psgi_qx callback
 	}
 	my $patchid = (split(/ /, $$bref))[0]; # ignore commit
 	$ctx->{-q_value_html} = "patchid:$patchid" if defined $patchid;
-	open my $fh, '<', "$ctx->{-tmp}/h" or
-		die "open $ctx->{-tmp}/h: $!";
+	open my $fh, '<', "$ctx->{-tmp}/h";
 	chop(my $buf = do { local $/ = "\0"; <$fh> });
 	utf8_maybe($buf); # non-UTF-8 commits exist
 	chomp $buf;
@@ -244,7 +244,7 @@ committer $co
 EOM
 	print $zfh "\n", $ctx->{-linkify}->to_html($bdy) if length($bdy);
 	$bdy = '';
-	open my $fh, '<', "$ctx->{-tmp}/p" or die "open $ctx->{-tmp}/p: $!";
+	open my $fh, '<', "$ctx->{-tmp}/p";
 	if (-s $fh > $MAX_SIZE) {
 		print $zfh "---\n patch is too large to show\n";
 	} else { # prepare flush_diff:
@@ -599,10 +599,7 @@ sub show ($$;$) {
 	}
 	$ctx->{fn} = $fn;
 	$ctx->{-tmp} = File::Temp->newdir("solver.$oid_b-XXXX", TMPDIR => 1);
-	unless ($ctx->{lh}) {
-		open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log" or
-			die "open: $!";
-	}
+	$ctx->{lh} or open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log";
 	my $solver = PublicInbox::SolverGit->new($ctx->{ibx},
 						\&solve_result, $ctx);
 	$solver->{gits} //= [ $ctx->{git} ];
diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm
index 3814f719..4ab9a77c 100644
--- a/lib/PublicInbox/WwwCoderepo.pm
+++ b/lib/PublicInbox/WwwCoderepo.pm
@@ -23,6 +23,7 @@ use PublicInbox::RepoList;
 use PublicInbox::OnDestroy;
 use URI::Escape qw(uri_escape_utf8);
 use File::Spec;
+use autodie qw(fcntl open);
 
 my @EACH_REF = (qw(git for-each-ref --sort=-creatordate),
 		"--format=%(HEAD)%00".join('%00', map { "%($_)" }
@@ -81,11 +82,11 @@ sub new {
 	$self->{$_} = 10 for qw(summary_log);
 
 	# try reuse STDIN if it's already /dev/null
-	open $self->{log_fh}, '+>', '/dev/null' or die "open: $!";
+	open $self->{log_fh}, '+>', '/dev/null';
 	my @l = stat($self->{log_fh}) or die "stat: $!";
 	my @s = stat(STDIN) or die "stat(STDIN): $!";
 	if ("@l[0, 1]" eq "@s[0, 1]") {
-		my $f = fcntl(STDIN, F_GETFL, 0) // die "F_GETFL: $!";
+		my $f = fcntl(STDIN, F_GETFL, 0);
 		$self->{log_fh} = *STDIN{IO} if $f & O_RDWR;
 	}
 	$self;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/6] WWW updates
@ 2024-01-09 11:39  6% Eric Wong
  2024-01-09 11:39  7% ` [PATCH 6/6] www: use autodie in more coderepo places Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2024-01-09 11:39 UTC (permalink / raw)
  To: meta

1/6 is something I hit on FreeBSD *shrug*
3/6 came out of an abandoned (for now) idea for the cache in 5/6
4/6 is preparation for 5/6
5/6 linkification is something I've wanted for a while, but held
off since it could get expensive and WWW is already slow enough.

More WWW stuff on the way to wire up coderepos for the release
(6/6 is the start of that) but ugh, my mind wanders towards
weird optimization ideas instead :x

Eric Wong (6):
  git: workaround occasional -watch error message
  doc: txt2pre: linkify -extindex(1), dedupe -config(5)
  test_common: key2sub: don't require final ';' in scripts
  git: lowercase host in host_prefix_url
  www: linkify inbox addresses in To/Cc headers
  www: use autodie in more coderepo places

 Documentation/txt2pre          |  2 +-
 lib/PublicInbox/Git.pm         | 13 ++++++-
 lib/PublicInbox/SearchView.pm  |  2 +-
 lib/PublicInbox/TestCommon.pm  |  2 +-
 lib/PublicInbox/View.pm        | 70 ++++++++++++++++++++++++++++++----
 lib/PublicInbox/ViewVCS.pm     | 11 ++----
 lib/PublicInbox/WwwCoderepo.pm |  5 ++-
 7 files changed, 84 insertions(+), 21 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2024-01-09 11:39  6% [PATCH 0/6] WWW updates Eric Wong
2024-01-09 11:39  7% ` [PATCH 6/6] www: use autodie in more coderepo places Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).