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

Function tokenHasWorkflowScope

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

tokenHasWorkflowScope checks if the response token has the workflow scope. Tokens that do not have OAuth scopes are assumed to have the workflow scope.

(headers http.Header)

Source from the content-addressed store, hash-verified

215// tokenHasWorkflowScope checks if the response token has the workflow scope.
216// Tokens that do not have OAuth scopes are assumed to have the workflow scope.
217func tokenHasWorkflowScope(headers http.Header) bool {
218 scopes := headers.Get("X-Oauth-Scopes")
219
220 // Return true when no scopes are present - no scopes in this header
221 // means that the user is probably authenticating with a token type other
222 // than an OAuth token, and we don't know what this token's scopes actually are.
223 if scopes == "" {
224 return true
225 }
226
227 // The API returns scopes separated by a comma and a space, so each element
228 // must be trimmed before comparison.
229 for s := range strings.SplitSeq(scopes, ",") {
230 if strings.TrimSpace(s) == "workflow" {
231 return true
232 }
233 }
234 return false
235}
236
237// isNewRelease checks if there are new commits since the latest release.
238func isNewRelease(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {

Callers 2

createReleaseFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 1