Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

fix(ci trace): exit normally when prompts are interrupted #849

Merged
merged 1 commit into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion commands/ci/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package trace

import (
"context"
"errors"
"fmt"
"regexp"

Expand All @@ -17,6 +18,7 @@ import (
"github.com/profclems/glab/pkg/utils"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/MakeNowJust/heredoc"
"github.com/spf13/cobra"
"github.com/xanzy/go-gitlab"
Expand Down Expand Up @@ -114,7 +116,14 @@ func TraceRun(opts *TraceOpts) error {
Options: jobOptions,
}

_ = prompt.AskOne(promptOpts, &selectedJob)
err = prompt.AskOne(promptOpts, &selectedJob)
if err != nil {
if errors.Is(err, terminal.InterruptErr) {
return nil
}

return err
}

if selectedJob != "" {
re := regexp.MustCompile(`(?s)\((.*)\)`)
Expand Down