From 290a138112b7f8b85ea5ee9bc2c2a27cd91d7efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20R=C3=BCttimann?= Date: Sun, 16 May 2021 18:21:46 +0200 Subject: [PATCH] Fix triggered jobs duration This commit fixes a bug where a `glab ci status` would panic if there is a job within that CI pipeline that is not triggered yet. In such a case, the StartedAt field is not populated, which triggered a panic. To fix this, we use `time.Now()` if `StartedAt` is nil, which means that the job will be displayed with a duration of 0. Fixes #727 --- commands/ci/status/status.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/ci/status/status.go b/commands/ci/status/status.go index edc2344c..d58de3e7 100644 --- a/commands/ci/status/status.go +++ b/commands/ci/status/status.go @@ -85,7 +85,12 @@ func NewCmdStatus(f *cmdutils.Factory) *cobra.Command { if job.FinishedAt != nil { end = *job.FinishedAt } - duration := utils.FmtDuration(end.Sub(*job.StartedAt)) + var duration string + if job.StartedAt != nil { + duration = utils.FmtDuration(end.Sub(*job.StartedAt)) + } else { + duration = "not started" + } var status string switch s := job.Status; s { case "failed":