Skip to content

Commit c06eacf

Browse files
committed
remove obsolete ensureScopes
1 parent d12ff4b commit c06eacf

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

command/root.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -261,46 +261,6 @@ var apiClientForContext = func(ctx context.Context) (*api.Client, error) {
261261
return api.NewClient(opts...), nil
262262
}
263263

264-
var ensureScopes = func(ctx context.Context, client *api.Client, wantedScopes ...string) (*api.Client, error) {
265-
hasScopes, appID, err := client.HasScopes(wantedScopes...)
266-
if err != nil {
267-
return client, err
268-
}
269-
270-
if hasScopes {
271-
return client, nil
272-
}
273-
274-
tokenFromEnv := len(os.Getenv("GITHUB_TOKEN")) > 0
275-
276-
if config.IsGitHubApp(appID) && !tokenFromEnv && utils.IsTerminal(os.Stdin) && utils.IsTerminal(os.Stderr) {
277-
cfg, err := ctx.Config()
278-
if err != nil {
279-
return nil, err
280-
}
281-
_, err = config.AuthFlowWithConfig(cfg, defaultHostname, "Notice: additional authorization required")
282-
if err != nil {
283-
return nil, err
284-
}
285-
286-
reloadedClient, err := apiClientForContext(ctx)
287-
if err != nil {
288-
return client, err
289-
}
290-
return reloadedClient, nil
291-
} else {
292-
fmt.Fprintf(os.Stderr, "Warning: gh now requires %s OAuth scopes.\n", wantedScopes)
293-
fmt.Fprintf(os.Stderr, "Visit https://github.com/settings/tokens and edit your token to enable %s\n", wantedScopes)
294-
if tokenFromEnv {
295-
fmt.Fprintln(os.Stderr, "or generate a new token for the GITHUB_TOKEN environment variable")
296-
} else {
297-
fmt.Fprintln(os.Stderr, "or generate a new token and paste it via `gh config set -h github.com oauth_token MYTOKEN`")
298-
}
299-
return client, errors.New("Unable to reauthenticate")
300-
}
301-
302-
}
303-
304264
func apiVerboseLog() api.ClientOption {
305265
logTraffic := strings.Contains(os.Getenv("DEBUG"), "api")
306266
colorize := utils.IsTerminal(os.Stderr)

command/testing.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ func initBlankContext(cfg, repo, branch string) {
9797

9898
func initFakeHTTP() *httpmock.Registry {
9999
http := &httpmock.Registry{}
100-
ensureScopes = func(ctx context.Context, client *api.Client, wantedScopes ...string) (*api.Client, error) {
101-
return client, nil
102-
}
103100
apiClientForContext = func(context.Context) (*api.Client, error) {
104101
return api.NewClient(api.ReplaceTripper(http)), nil
105102
}

0 commit comments

Comments
 (0)