X Tutup
Skip to content

Commit ba0a441

Browse files
committed
Allow configuring the update notifier from the outside
To test the update notifier: rm -f bin/gh; GH_VERSION=v0.2.3 LDFLAGS='-X main.updaterEnabled=github/homebrew-gh' make
1 parent 67f0cf3 commit ba0a441

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ builds:
99
- -s -w -X github.com/github/gh-cli/command.Version={{.Version}} -X github.com/github/gh-cli/command.BuildDate={{.Date}}
1010
- -X github.com/github/gh-cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}}
1111
- -X github.com/github/gh-cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}}
12-
- -X github.com/github/gh-cli.updaterEnabled=yes
12+
- -X main.updaterEnabled=github/homebrew-gh
1313
goos:
1414
- linux
1515
- darwin

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BUILD_FILES = $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}}\
22
{{end}}' ./...)
33

4-
GH_VERSION = $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
4+
GH_VERSION ?= $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
55
LDFLAGS := -X github.com/github/gh-cli/command.Version=$(GH_VERSION) $(LDFLAGS)
66
LDFLAGS := -X github.com/github/gh-cli/command.BuildDate=$(shell date +%Y-%m-%d) $(LDFLAGS)
77
ifdef GH_OAUTH_CLIENT_SECRET

main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/mgutz/ansi"
1313
)
1414

15-
var updaterEnabled = "no"
15+
var updaterEnabled = ""
1616

1717
func main() {
1818
currentVersion := command.Version
@@ -42,7 +42,7 @@ Release notes: %s`, currentVersion, newRelease.Version, newRelease.URL)
4242

4343
func shouldCheckForUpdate() bool {
4444
errFd := os.Stderr.Fd()
45-
return updaterEnabled == "yes" && (isatty.IsTerminal(errFd) || isatty.IsCygwinTerminal(errFd))
45+
return updaterEnabled != "" && (isatty.IsTerminal(errFd) || isatty.IsCygwinTerminal(errFd))
4646
}
4747

4848
func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
@@ -55,5 +55,6 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
5555
return nil, err
5656
}
5757

58-
return update.CheckForUpdate(client, "github/homebrew-gh", currentVersion)
58+
repo := updaterEnabled
59+
return update.CheckForUpdate(client, repo, currentVersion)
5960
}

0 commit comments

Comments
 (0)
X Tutup