MCPcopy
hub / github.com/cli/cli / tokenHasWorkflowScope

Function tokenHasWorkflowScope

pkg/cmd/release/create/http.go:291–302  ·  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

289// tokenHasWorkflowScope checks if the given http.Response's token has the workflow scope.
290// Tokens that do not have OAuth scopes are assumed to have the workflow scope.
291func tokenHasWorkflowScope(resp *http.Response) bool {
292 scopes := resp.Header.Get("X-Oauth-Scopes")
293
294 // Return true when no scopes are present - no scopes in this header
295 // means that the user is probably authenticating with a token type other
296 // than an OAuth token, and we don't know what this token's scopes actually are.
297 if scopes == "" {
298 return true
299 }
300
301 return slices.Contains(strings.Split(scopes, ","), "workflow")
302}
303
304// isNewRelease checks if there are new commits since the latest release.
305func 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