Skip to content

feat: show banner when workspace is outdated #4926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address PR comments
  • Loading branch information
mtojek committed Nov 7, 2022
commit b50d2fe74f6da07d48299e0e1a57ceb9d40b7d05
4 changes: 2 additions & 2 deletions cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func ssh() *cobra.Command {
}

updateWorkspaceBanner, outdated := verifyWorkspaceOutdated(client, workspace)
if outdated {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), updateWorkspaceBanner)
if outdated && isTTYOut(cmd) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this tty check is only for stdout which doesn't help us (we want to confirm stderr.)

Made the following quick test:

❯ go run main.go >/dev/null
stdout isatty: false
stderr isatty: true

❯ go run main.go 2>/dev/null
stdout isatty: true
stderr isatty: false

Using:

package main

import (
	"fmt"
	"io"
	"os"

	"github.com/mattn/go-isatty"
)

func main() {
	both := io.MultiWriter(os.Stdout, os.Stderr)
	fmt.Fprintf(both, "stdout isatty: %v\n", isatty.IsTerminal(os.Stdout.Fd()))
	fmt.Fprintf(both, "stderr isatty: %v\n", isatty.IsTerminal(os.Stderr.Fd()))
}

Arguably, this is a bug we potentially have across our whole CLI, but for now I think we can just add a new function: isTTYErr.

Copy link
Member Author

@mtojek mtojek Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the snippet. I refactored the original isTTYOut function, but please let me know what you think.

_, _ = fmt.Fprintln(cmd.ErrOrStderr(), updateWorkspaceBanner)
}

// OpenSSH passes stderr directly to the calling TTY.
Expand Down