Skip to content

Commit a2aa07d

Browse files
authored
Merge pull request cli#2134 from ShubhankarKG/updates
Update shouldCheckForUpdate
2 parents 338e036 + ce8f37a commit a2aa07d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cmd/gh/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,17 @@ func printError(out io.Writer, err error, cmd *cobra.Command, debug bool) {
186186
}
187187

188188
func shouldCheckForUpdate() bool {
189-
return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr)
189+
if os.Getenv("GH_NO_UPDATE_NOTIFIER") != "" {
190+
return false
191+
}
192+
return updaterEnabled != "" && !isCI() && !isCompletionCommand() && utils.IsTerminal(os.Stderr)
193+
}
194+
195+
// based on https://github.com/watson/ci-info/blob/HEAD/index.js
196+
func isCI() bool {
197+
return os.Getenv("CI") != "" || // GitHub Actions, Travis CI, CircleCI, Cirrus CI, GitLab CI, AppVeyor, CodeShip, dsari
198+
os.Getenv("BUILD_NUMBER") != "" || // Jenkins, TeamCity
199+
os.Getenv("RUN_ID") != "" // TaskCluster, dsari
190200
}
191201

192202
func isCompletionCommand() bool {

pkg/cmd/root/help_topic.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func NewHelpTopic(topic string) *cobra.Command {
3939
4040
CLICOLOR_FORCE: set to a value other than "0" to keep ANSI colors in output
4141
even when the output is piped.
42+
43+
GH_NO_UPDATE_NOTIFIER: set to any value to disable update notifications. By default, gh
44+
checks for new releases once every 24 hours and displays an upgrade notice on standard
45+
error if a newer version was found.
4246
`)
4347

4448
cmd := &cobra.Command{

0 commit comments

Comments
 (0)