diff --git a/main.go b/main.go index 558c81cc7..80bf075c6 100644 --- a/main.go +++ b/main.go @@ -6,11 +6,12 @@ import ( "strings" "github.com/github/gh-cli/command" + "github.com/github/gh-cli/update" ) func main() { printUpdateMessage := make(chan func()) - go command.CheckForUpdate(printUpdateMessage) + go update.CheckForUpdate(printUpdateMessage) if cmd, err := command.RootCmd.ExecuteC(); err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/command/checkForUpdate.go b/update/checkForUpdate.go similarity index 81% rename from command/checkForUpdate.go rename to update/checkForUpdate.go index d49182348..a16009a6f 100644 --- a/command/checkForUpdate.go +++ b/update/checkForUpdate.go @@ -1,4 +1,4 @@ -package command +package update import ( "encoding/json" @@ -7,6 +7,7 @@ import ( "net/http" "os" + "github.com/github/gh-cli/command" "github.com/github/gh-cli/utils" "golang.org/x/crypto/ssh/terminal" ) @@ -28,14 +29,14 @@ func CheckForUpdate(handleUpdate chan func()) { handleUpdate <- nil } - updateAvailable := latestRelease.Version != Version + updateAvailable := latestRelease.Version != command.Version if updateAvailable { handleUpdate <- func() { fmt.Printf(utils.Cyan(` A new version of gh is available! %s → %s Changelog: %s -Run 'brew reinstall gh' to update!`)+"\n\n", Version, latestRelease.Version, latestRelease.URL) +Run 'brew reinstall gh' to update!`)+"\n\n", command.Version, latestRelease.Version, latestRelease.URL) } } else { handleUpdate <- nil @@ -57,5 +58,5 @@ func getLatestRelease() (*releaseInfo, error) { var r releaseInfo json.Unmarshal(data, &r) - return r, nil + return &r, nil }