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)
| 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. |
| 217 | func 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. |
| 238 | func isNewRelease(httpClient *http.Client, repo ghrepo.Interface) (bool, error) { |