X Tutup
Skip to content

Commit 9df3bd9

Browse files
committed
Change command pkg to build pkg
1 parent 0f8084d commit 9df3bd9

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ifndef CGO_LDFLAGS
1919
export CGO_LDFLAGS := $(LDFLAGS)
2020
endif
2121

22-
GO_LDFLAGS := -X github.com/cli/cli/command.Version=$(GH_VERSION) $(GO_LDFLAGS)
23-
GO_LDFLAGS := -X github.com/cli/cli/command.BuildDate=$(BUILD_DATE) $(GO_LDFLAGS)
22+
GO_LDFLAGS := -X github.com/cli/cli/build.Version=$(GH_VERSION) $(GO_LDFLAGS)
23+
GO_LDFLAGS := -X github.com/cli/cli/build.Date=$(BUILD_DATE) $(GO_LDFLAGS)
2424
ifdef GH_OAUTH_CLIENT_SECRET
2525
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientID=$(GH_OAUTH_CLIENT_ID) $(GO_LDFLAGS)
2626
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientSecret=$(GH_OAUTH_CLIENT_SECRET) $(GO_LDFLAGS)

command/root.go renamed to build/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package command
1+
package build
22

33
import (
44
"runtime/debug"
@@ -7,8 +7,8 @@ import (
77
// Version is dynamically set by the toolchain or overridden by the Makefile.
88
var Version = "DEV"
99

10-
// BuildDate is dynamically set at build time in the Makefile.
11-
var BuildDate = "" // YYYY-MM-DD
10+
// Date is dynamically set at build time in the Makefile.
11+
var Date = "" // YYYY-MM-DD
1212

1313
func init() {
1414
if Version == "DEV" {

cmd/gh/main.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
surveyCore "github.com/AlecAivazis/survey/v2/core"
1414
"github.com/cli/cli/api"
15-
"github.com/cli/cli/command"
15+
"github.com/cli/cli/build"
1616
"github.com/cli/cli/internal/config"
1717
"github.com/cli/cli/internal/ghinstance"
1818
"github.com/cli/cli/internal/run"
@@ -29,10 +29,12 @@ import (
2929
var updaterEnabled = ""
3030

3131
func main() {
32-
currentVersion := command.Version
32+
buildDate := build.Date
33+
buildVersion := build.Version
34+
3335
updateMessageChan := make(chan *update.ReleaseInfo)
3436
go func() {
35-
rel, _ := checkForUpdate(currentVersion)
37+
rel, _ := checkForUpdate(buildVersion)
3638
updateMessageChan <- rel
3739
}()
3840

@@ -42,7 +44,7 @@ func main() {
4244
ghinstance.OverrideDefault(hostFromEnv)
4345
}
4446

45-
cmdFactory := factory.New(command.Version)
47+
cmdFactory := factory.New(buildVersion)
4648
stderr := cmdFactory.IOStreams.ErrOut
4749
if !cmdFactory.IOStreams.ColorEnabled() {
4850
surveyCore.DisableColor = true
@@ -61,7 +63,7 @@ func main() {
6163
}
6264
}
6365

64-
rootCmd := root.NewCmdRoot(cmdFactory, command.Version, command.BuildDate)
66+
rootCmd := root.NewCmdRoot(cmdFactory, buildVersion, buildDate)
6567

6668
cfg, err := cmdFactory.Config()
6769
if err != nil {
@@ -151,7 +153,7 @@ func main() {
151153
if newRelease != nil {
152154
msg := fmt.Sprintf("%s %s → %s\n%s",
153155
ansi.Color("A new release of gh is available:", "yellow"),
154-
ansi.Color(currentVersion, "cyan"),
156+
ansi.Color(buildVersion, "cyan"),
155157
ansi.Color(newRelease.Version, "cyan"),
156158
ansi.Color(newRelease.URL, "yellow"))
157159

@@ -208,7 +210,7 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
208210
return nil, nil
209211
}
210212

211-
client, err := basicClient()
213+
client, err := basicClient(currentVersion)
212214
if err != nil {
213215
return nil, err
214216
}
@@ -220,12 +222,12 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
220222

221223
// BasicClient returns an API client for github.com only that borrows from but
222224
// does not depend on user configuration
223-
func basicClient() (*api.Client, error) {
225+
func basicClient(currentVersion string) (*api.Client, error) {
224226
var opts []api.ClientOption
225227
if verbose := os.Getenv("DEBUG"); verbose != "" {
226228
opts = append(opts, apiVerboseLog())
227229
}
228-
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", command.Version)))
230+
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", currentVersion)))
229231

230232
token := os.Getenv("GITHUB_TOKEN")
231233
if token == "" {

0 commit comments

Comments
 (0)
X Tutup