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

Function tokenHasWorkflowScope

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

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

Callers 2

createReleaseFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 1