MCPcopy Create free account
hub / github.com/cli/cli / tokenHasWorkflowScope

Function tokenHasWorkflowScope

pkg/cmd/release/create/http.go:301–312  ·  view source on GitHub ↗

tokenHasWorkflowScope checks if the given http.Response's token has the workflow scope. Tokens that do not have OAuth scopes are assumed to have the workflow scope.

(resp *http.Response)

Source from the content-addressed store, hash-verified

299// tokenHasWorkflowScope checks if the given http.Response's token has the workflow scope.
300// Tokens that do not have OAuth scopes are assumed to have the workflow scope.
301func tokenHasWorkflowScope(resp *http.Response) bool {
302 scopes := resp.Header.Get("X-Oauth-Scopes")
303
304 // Return true when no scopes are present - no scopes in this header
305 // means that the user is probably authenticating with a token type other
306 // than an OAuth token, and we don't know what this token's scopes actually are.
307 if scopes == "" {
308 return true
309 }
310
311 return slices.Contains(strings.Split(scopes, ","), "workflow")
312}
313
314// isNewRelease checks if there are new commits since the latest release.
315func isNewRelease(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {

Callers 1

createReleaseFunction · 0.85

Calls 2

ContainsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected