diff --git a/action/pipeline/exec.go b/action/pipeline/exec.go index 8d271837..65ce5db6 100644 --- a/action/pipeline/exec.go +++ b/action/pipeline/exec.go @@ -328,14 +328,14 @@ func formatStepIdentifier(stageName, stepName string, isSecret bool) string { output := strings.Builder{} if stageName != "" { - output.WriteString(fmt.Sprintf(stagePrefix, stageName)) + fmt.Fprintf(&output, stagePrefix, stageName) } if stepName != "" { if isSecret { - output.WriteString(fmt.Sprintf(secretPrefix, stepName)) + fmt.Fprintf(&output, secretPrefix, stepName) } else { - output.WriteString(fmt.Sprintf(stepPrefix, stepName)) + fmt.Fprintf(&output, stepPrefix, stepName) } } diff --git a/action/secret/add.go b/action/secret/add.go index f94d24ff..3712a304 100644 --- a/action/secret/add.go +++ b/action/secret/add.go @@ -1,6 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl // ignore similar code among actions package secret import ( diff --git a/action/secret/update.go b/action/secret/update.go index a2400d76..53207e9b 100644 --- a/action/secret/update.go +++ b/action/secret/update.go @@ -1,6 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl // ignore similar code among actions package secret import ( diff --git a/internal/output/color.go b/internal/output/color.go index 146ce909..6478cb61 100644 --- a/internal/output/color.go +++ b/internal/output/color.go @@ -4,6 +4,7 @@ package output import ( "bytes" + "math" "os" chroma "github.com/alecthomas/chroma/v2/quick" @@ -78,7 +79,11 @@ func shouldEnableColor(c *cli.Command) bool { } // 5. If not a terminal, don't use color by default - if !term.IsTerminal(int(os.Stdout.Fd())) { + fd := os.Stdout.Fd() + + // maxInt is the largest value that fits in an int for the current arch. + maxInt := uintptr(math.MaxInt) + if fd > maxInt || !term.IsTerminal(int(fd)) { logrus.Debug("no TTY, colors will be suppressed") return false