X Tutup
Skip to content

Commit ce8f37a

Browse files
committed
💅 tweak update notifier
1 parent 78b67fa commit ce8f37a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cmd/gh/main.go

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

188188
func shouldCheckForUpdate() bool {
189-
isCIEnvironment := (os.Getenv("CI") != "") || (os.Getenv("BUILD_NUMBER") != "") || (os.Getenv("RUN_ID") != "")
190-
isGlobalDisabled := os.Getenv("GH_NO_UPDATE_NOTIFIER") != ""
191-
return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr) && !isCIEnvironment && !isGlobalDisabled
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
192200
}
193201

194202
func isCompletionCommand() bool {

pkg/cmd/root/help_topic.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func NewHelpTopic(topic string) *cobra.Command {
4040
CLICOLOR_FORCE: set to a value other than "0" to keep ANSI colors in output
4141
even when the output is piped.
4242
43-
GH_NO_UPDATE_NOTIFIER: set to "1" to disable checking for updates.
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.
4446
`)
4547

4648
cmd := &cobra.Command{

0 commit comments

Comments
 (0)
X Tutup