Update shouldCheckForUpdate

This commit is contained in:
ShubhankarKG 2020-10-08 12:04:57 +05:30
parent 0d593e78aa
commit 3a22ab7eba
2 changed files with 8 additions and 4 deletions

View file

@ -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 {

View file

@ -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.