Change command pkg to build pkg
This commit is contained in:
parent
0f8084d039
commit
9df3bd9344
3 changed files with 16 additions and 14 deletions
4
Makefile
4
Makefile
|
|
@ -19,8 +19,8 @@ ifndef CGO_LDFLAGS
|
|||
export CGO_LDFLAGS := $(LDFLAGS)
|
||||
endif
|
||||
|
||||
GO_LDFLAGS := -X github.com/cli/cli/command.Version=$(GH_VERSION) $(GO_LDFLAGS)
|
||||
GO_LDFLAGS := -X github.com/cli/cli/command.BuildDate=$(BUILD_DATE) $(GO_LDFLAGS)
|
||||
GO_LDFLAGS := -X github.com/cli/cli/build.Version=$(GH_VERSION) $(GO_LDFLAGS)
|
||||
GO_LDFLAGS := -X github.com/cli/cli/build.Date=$(BUILD_DATE) $(GO_LDFLAGS)
|
||||
ifdef GH_OAUTH_CLIENT_SECRET
|
||||
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientID=$(GH_OAUTH_CLIENT_ID) $(GO_LDFLAGS)
|
||||
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientSecret=$(GH_OAUTH_CLIENT_SECRET) $(GO_LDFLAGS)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package command
|
||||
package build
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
|
|
@ -7,8 +7,8 @@ import (
|
|||
// Version is dynamically set by the toolchain or overridden by the Makefile.
|
||||
var Version = "DEV"
|
||||
|
||||
// BuildDate is dynamically set at build time in the Makefile.
|
||||
var BuildDate = "" // YYYY-MM-DD
|
||||
// Date is dynamically set at build time in the Makefile.
|
||||
var Date = "" // YYYY-MM-DD
|
||||
|
||||
func init() {
|
||||
if Version == "DEV" {
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
surveyCore "github.com/AlecAivazis/survey/v2/core"
|
||||
"github.com/cli/cli/api"
|
||||
"github.com/cli/cli/command"
|
||||
"github.com/cli/cli/build"
|
||||
"github.com/cli/cli/internal/config"
|
||||
"github.com/cli/cli/internal/ghinstance"
|
||||
"github.com/cli/cli/internal/run"
|
||||
|
|
@ -29,10 +29,12 @@ import (
|
|||
var updaterEnabled = ""
|
||||
|
||||
func main() {
|
||||
currentVersion := command.Version
|
||||
buildDate := build.Date
|
||||
buildVersion := build.Version
|
||||
|
||||
updateMessageChan := make(chan *update.ReleaseInfo)
|
||||
go func() {
|
||||
rel, _ := checkForUpdate(currentVersion)
|
||||
rel, _ := checkForUpdate(buildVersion)
|
||||
updateMessageChan <- rel
|
||||
}()
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ func main() {
|
|||
ghinstance.OverrideDefault(hostFromEnv)
|
||||
}
|
||||
|
||||
cmdFactory := factory.New(command.Version)
|
||||
cmdFactory := factory.New(buildVersion)
|
||||
stderr := cmdFactory.IOStreams.ErrOut
|
||||
if !cmdFactory.IOStreams.ColorEnabled() {
|
||||
surveyCore.DisableColor = true
|
||||
|
|
@ -61,7 +63,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
rootCmd := root.NewCmdRoot(cmdFactory, command.Version, command.BuildDate)
|
||||
rootCmd := root.NewCmdRoot(cmdFactory, buildVersion, buildDate)
|
||||
|
||||
cfg, err := cmdFactory.Config()
|
||||
if err != nil {
|
||||
|
|
@ -151,7 +153,7 @@ func main() {
|
|||
if newRelease != nil {
|
||||
msg := fmt.Sprintf("%s %s → %s\n%s",
|
||||
ansi.Color("A new release of gh is available:", "yellow"),
|
||||
ansi.Color(currentVersion, "cyan"),
|
||||
ansi.Color(buildVersion, "cyan"),
|
||||
ansi.Color(newRelease.Version, "cyan"),
|
||||
ansi.Color(newRelease.URL, "yellow"))
|
||||
|
||||
|
|
@ -208,7 +210,7 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
client, err := basicClient()
|
||||
client, err := basicClient(currentVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -220,12 +222,12 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
|
|||
|
||||
// BasicClient returns an API client for github.com only that borrows from but
|
||||
// does not depend on user configuration
|
||||
func basicClient() (*api.Client, error) {
|
||||
func basicClient(currentVersion string) (*api.Client, error) {
|
||||
var opts []api.ClientOption
|
||||
if verbose := os.Getenv("DEBUG"); verbose != "" {
|
||||
opts = append(opts, apiVerboseLog())
|
||||
}
|
||||
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", command.Version)))
|
||||
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", currentVersion)))
|
||||
|
||||
token := os.Getenv("GITHUB_TOKEN")
|
||||
if token == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue