From 14a804ad43acc7f18efba1483767ec28039004fa Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 3 Jul 2025 12:04:17 -0400 Subject: [PATCH] fix(ssh): honor SOFT_SERVE_NO_COLOR env var in blob command --- pkg/ssh/cmd/blob.go | 9 +++++++-- pkg/ssh/session.go | 8 +------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/ssh/cmd/blob.go b/pkg/ssh/cmd/blob.go index 45e0affb2ad7c0cc9b9a82efecf0fc8e177e63d7..1aa8fbbe16ffc50c116c4e267f986d20663dcc8f 100644 --- a/pkg/ssh/cmd/blob.go +++ b/pkg/ssh/cmd/blob.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/pkg/backend" @@ -15,6 +16,10 @@ func blobCommand() *cobra.Command { var linenumber bool var color bool var raw bool + var noColor bool + if testrun, ok := os.LookupEnv("SOFT_SERVE_NO_COLOR"); ok && testrun == "1" { + noColor = true + } styles := styles.DefaultStyles() cmd := &cobra.Command{ @@ -83,7 +88,7 @@ func blobCommand() *cobra.Command { return fmt.Errorf("binary file: use --raw to print") } } else { - if color { + if color && !noColor { c, err = common.FormatHighlight(fp, c) if err != nil { return err @@ -91,7 +96,7 @@ func blobCommand() *cobra.Command { } if linenumber { - c, _ = common.FormatLineNumber(styles, c, color) + c, _ = common.FormatLineNumber(styles, c, color && !noColor) } cmd.Println(c) diff --git a/pkg/ssh/session.go b/pkg/ssh/session.go index 067acb4286c9eb1526d6245192abe4b1f9c981ed..892da8bba0de8330c6761e0e30a76adbd80afe12 100644 --- a/pkg/ssh/session.go +++ b/pkg/ssh/session.go @@ -1,11 +1,9 @@ package ssh import ( - "os" "time" tea "github.com/charmbracelet/bubbletea/v2" - "github.com/charmbracelet/colorprofile" "github.com/charmbracelet/soft-serve/pkg/access" "github.com/charmbracelet/soft-serve/pkg/backend" "github.com/charmbracelet/soft-serve/pkg/config" @@ -60,13 +58,9 @@ func SessionHandler(s ssh.Session) *tea.Program { tea.WithoutCatchPanics(), tea.WithMouseCellMotion(), tea.WithContext(ctx), + tea.WithColorProfile(common.DefaultColorProfile), ) - if testrun, ok := os.LookupEnv("SOFT_SERVE_NO_COLOR"); ok && testrun == "1" { - // Disable colors when running tests. - opts = append(opts, tea.WithColorProfile(colorprofile.NoTTY)) - } - c := common.NewCommon(ctx, pty.Window.Width, pty.Window.Height) c.SetValue(common.ConfigKey, cfg) m := NewUI(c, initialRepo)