From 3a22ab7eba1971ef7bb760b5f497499390cd37cc Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 8 Oct 2020 12:04:57 +0530 Subject: [PATCH] Update shouldCheckForUpdate --- cmd/gh/main.go | 4 +++- internal/config/config_type.go | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/gh/main.go b/cmd/gh/main.go index db329c3cd..5fc4c2385 100644 --- a/cmd/gh/main.go +++ b/cmd/gh/main.go @@ -186,7 +186,9 @@ func printError(out io.Writer, err error, cmd *cobra.Command, debug bool) { } func shouldCheckForUpdate() bool { - return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr) + isCIEnvironment := (os.Getenv("CI") != "") || (os.Getenv("BUILD_NUMBER") != "") || (os.Getenv("RUN_ID") != "") + isGlobalDisabled := os.Getenv("GH_NO_UPDATE_NOTIFIER") == "disabled" + return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr) && !isCIEnvironment && !isGlobalDisabled } func isCompletionCommand() bool { diff --git a/internal/config/config_type.go b/internal/config/config_type.go index 0fd85d7f0..e9bf00f28 100644 --- a/internal/config/config_type.go +++ b/internal/config/config_type.go @@ -11,9 +11,11 @@ import ( ) const ( - defaultGitProtocol = "https" - PromptsDisabled = "disabled" - PromptsEnabled = "enabled" + defaultGitProtocol = "https" + PromptsDisabled = "disabled" + PromptsEnabled = "enabled" + UpdateCheckEnabled = "enabled" + UpdateCheckDisabled = "disabled" ) // This interface describes interacting with some persistent configuration for gh.