Skip to content

Commit 98b844a

Browse files
authored
Merge pull request #11024 from cli/kw/cli-10242-fix-updater-notifications
Fix brew update notifications
2 parents 4fcd6bf + dd4095d commit 98b844a

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

internal/ghcmd/cmd.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ import (
2929
"github.com/spf13/cobra"
3030
)
3131

32-
// updaterEnabled is a statically linked build property set in gh formula within homebrew/homebrew-core
33-
// used to control whether users are notified of newer GitHub CLI releases.
34-
// This needs to be set to 'cli/cli' as it affects where update.CheckForUpdate() checks for releases.
35-
// It is unclear whether this means that only homebrew builds will check for updates or not.
36-
// Development builds leave this empty as impossible to determine if newer or not.
37-
// For more information, <https://github.com/Homebrew/homebrew-core/blob/master/Formula/g/gh.rb>.
38-
var updaterEnabled = ""
39-
4032
type exitCode int
4133

4234
const (

internal/ghcmd/update_disabled.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build !updateable
2+
3+
package ghcmd
4+
5+
// See update_enabled.go comment for more information.
6+
var updaterEnabled = ""

internal/ghcmd/update_enabled.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build updateable
2+
3+
package ghcmd
4+
5+
// `updateable` is a build tag set in the gh formula within homebrew/homebrew-core
6+
// and is used to control whether users are notified of newer GitHub CLI releases.
7+
//
8+
// Currently, updaterEnabled needs to be set to 'cli/cli' as it affects where
9+
// update.CheckForUpdate() checks for releases. It is unclear to what extent
10+
// this updaterEnabled is being used by unofficial forks or builds, so we decided
11+
// to leave it available for injection as a string variable for now.
12+
//
13+
// Development builds do not generate update messages by default.
14+
//
15+
// For more information, see:
16+
// - the Homebrew formula for gh: <https://github.com/Homebrew/homebrew-core/blob/master/Formula/g/gh.rb>.
17+
// - a discussion about adding this build tag: <https://github.com/cli/cli/pull/11024#discussion_r2107597618>.
18+
var updaterEnabled = "cli/cli"

script/build.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ var tasks = map[string]func(string) error{
5353
ldflags = fmt.Sprintf("-X github.com/cli/cli/v2/internal/authflow.oauthClientID=%s %s", os.Getenv("GH_OAUTH_CLIENT_ID"), ldflags)
5454
}
5555

56-
return run("go", "build", "-trimpath", "-ldflags", ldflags, "-o", exe, "./cmd/gh")
56+
buildTags, _ := os.LookupEnv("GO_BUILDTAGS")
57+
58+
args := []string{"go", "build", "-trimpath"}
59+
if buildTags != "" {
60+
args = append(args, "-tags", buildTags)
61+
}
62+
args = append(args, "-ldflags", ldflags, "-o", exe, "./cmd/gh")
63+
64+
return run(args...)
5765
},
5866
"manpages": func(_ string) error {
5967
return run("go", "run", "./cmd/gen-docs", "--man-page", "--doc-path", "./share/man/man1/")

0 commit comments

Comments
 (0)