From c63247f0eac867fb406388d848db2f4b5986622b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 4 Mar 2021 17:39:25 +0100 Subject: [PATCH] Avoid checking for new releases when authenticating git Avoid displaying upgrade notice if any output is redirected. This also alleviates the need to specifically check for `gh completion -s `, `gh __complete`, and other scripting scenarios where we absolutely don't want to trigger any upgrade checks or notices. --- cmd/gh/main.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/gh/main.go b/cmd/gh/main.go index e8471da8d..bb399f1a5 100644 --- a/cmd/gh/main.go +++ b/cmd/gh/main.go @@ -236,7 +236,7 @@ func shouldCheckForUpdate() bool { if os.Getenv("CODESPACES") != "" { return false } - return updaterEnabled != "" && !isCI() && !isCompletionCommand() && utils.IsTerminal(os.Stderr) + return updaterEnabled != "" && !isCI() && utils.IsTerminal(os.Stdout) && utils.IsTerminal(os.Stderr) } // based on https://github.com/watson/ci-info/blob/HEAD/index.js @@ -246,10 +246,6 @@ func isCI() bool { os.Getenv("RUN_ID") != "" // TaskCluster, dsari } -func isCompletionCommand() bool { - return len(os.Args) > 1 && os.Args[1] == "completion" -} - func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) { if !shouldCheckForUpdate() { return nil, nil