X Tutup
Skip to content

Commit 414de33

Browse files
committed
cleanup
1 parent a79a0bb commit 414de33

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

cmd/gh/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,11 @@ func main() {
136136

137137
cs := cmdFactory.IOStreams.ColorScheme()
138138

139-
// _, _, tokenPresent := config.AuthTokenFromEnv(ghinstance.OverridableDefault())
140-
// authCheckEnabled := !tokenPresent && cmd != nil && cmdutil.IsAuthCheckEnabled(cmd)
141-
authCheckEnabled := cmd != nil && cmdutil.IsAuthCheckEnabled(cmd)
142-
if authCheckEnabled && !cmdutil.CheckAuth(cfg) {
139+
if cmd != nil && cmdutil.IsAuthCheckEnabled(cmd) && !cmdutil.CheckAuth(cfg) {
143140
fmt.Fprintln(stderr, cs.Bold("Welcome to GitHub CLI!"))
144141
fmt.Fprintln(stderr)
145142
fmt.Fprintln(stderr, "To authenticate, please run `gh auth login`.")
146-
fmt.Fprintln(stderr, "You can also set the one of the oauth token environment variables, if preferred.")
143+
fmt.Fprintln(stderr, "You can also set the one of the auth token environment variables, if preferred.")
147144
os.Exit(4)
148145
}
149146

@@ -246,8 +243,8 @@ func basicClient(currentVersion string) (*api.Client, error) {
246243
}
247244
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", currentVersion)))
248245

249-
token, _, ok := config.AuthTokenFromEnv(ghinstance.Default())
250-
if !ok {
246+
token, _, found := config.AuthTokenFromEnv(ghinstance.Default())
247+
if !found {
251248
if c, err := config.ParseDefaultConfig(); err == nil {
252249
token, _ = c.Get(ghinstance.Default(), "oauth_token")
253250
}

internal/config/from_env.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func (c *envConfig) Get(hostname, key string) (string, error) {
4545

4646
func (c *envConfig) GetWithSource(hostname, key string) (string, string, error) {
4747
if hostname != "" && key == "oauth_token" {
48-
if value, name, found := AuthTokenFromEnv(hostname); found {
49-
return value, name, nil
48+
if token, env, found := AuthTokenFromEnv(hostname); found {
49+
return token, env, nil
5050
}
5151
}
5252

@@ -55,8 +55,8 @@ func (c *envConfig) GetWithSource(hostname, key string) (string, string, error)
5555

5656
func (c *envConfig) CheckWriteable(hostname, key string) error {
5757
if hostname != "" && key == "oauth_token" {
58-
if _, name, found := AuthTokenFromEnv(hostname); found {
59-
return fmt.Errorf("read-only token in %s cannot be modified", name)
58+
if _, env, found := AuthTokenFromEnv(hostname); found {
59+
return fmt.Errorf("read-only token in %s cannot be modified", env)
6060
}
6161
}
6262

pkg/cmd/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ original query accepts an '$endCursor: String' variable and that it fetches the
119119
`),
120120
Annotations: map[string]string{
121121
"help:environment": heredoc.Doc(`
122-
GH_TOKEN, GITHUB_TOKEN (in order of procedence): an authentication token for github.com API requests.
122+
GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for github.com API requests.
123123
124-
GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of procedence): an authentication token for API requests to GitHub Enterprise.
124+
GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of precedence): an authentication token for API requests to GitHub Enterprise.
125125
126126
GH_HOST: make the request to a GitHub host other than github.com.
127127
`),

pkg/cmd/root/help_topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var HelpTopics = map[string]map[string]string{
99
"environment": {
1010
"short": "Environment variables that can be used with gh",
1111
"long": heredoc.Doc(`
12-
GH_TOKEN, GITHUB_TOKEN (in order of procedence): an authentication token for github.com
12+
GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for github.com
1313
API requests. Setting this avoids being prompted to authenticate and takes precedence over
1414
previously stored credentials.
1515

0 commit comments

Comments
 (0)
X Tutup