From 1d0076408b5df483367e5fe80a8fbf8c45907e62 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 26 Jan 2022 12:36:25 -0800 Subject: [PATCH] Controller/Build: pass log_uri to showLog in place of drvPath This way, we can reuse the `showLog` sub for other things, such as `view_runcommandlog` (which doesn't have a drvPath attached). --- src/lib/Hydra/Controller/Build.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index b2303e08..1b2be1eb 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -126,13 +126,18 @@ sub view_nixlog : Chained('buildChain') PathPart('nixlog') { $c->stash->{step} = $step; - showLog($c, $mode, $step->drvpath); + my $drvPath = $step->drvpath; + my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]); + showLog($c, $mode, $log_uri); } sub view_log : Chained('buildChain') PathPart('log') { my ($self, $c, $mode) = @_; - showLog($c, $mode, $c->stash->{build}->drvpath); + + my $drvPath = $c->stash->{build}->drvpath; + my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]); + showLog($c, $mode, $log_uri); } @@ -145,11 +150,9 @@ sub view_runcommandlog : Chained('buildChain') PathPart('runcommandlog') { sub showLog { - my ($c, $mode, $drvPath) = @_; + my ($c, $mode, $log_uri) = @_; $mode //= "pretty"; - my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]); - if ($mode eq "pretty") { $c->stash->{log_uri} = $log_uri; $c->stash->{template} = 'log.tt';