Recognize the write:org OAuth scope as satisfying read:org

If someone pastes a PAT with `write:org` scope, this avoids the error
complaining that the token doesn't have `read:org` permissions. On
GitHub, `write:org` implies `read:org`.
This commit is contained in:
Mislav Marohnić 2021-02-15 17:52:41 +01:00
parent 4e5aa91fac
commit 0be2033d51
2 changed files with 6 additions and 1 deletions

View file

@ -216,7 +216,7 @@ func (c Client) HasMinimumScopes(hostname string) error {
missingScopes = append(missingScopes, "repo")
}
if !search["read:org"] && !search["admin:org"] {
if !search["read:org"] && !search["write:org"] && !search["admin:org"] {
missingScopes = append(missingScopes, "read:org")
}

View file

@ -131,6 +131,11 @@ func Test_HasMinimumScopes(t *testing.T) {
header: "repo, admin:org",
wantErr: "",
},
{
name: "write:org satisfies read:org",
header: "repo, write:org",
wantErr: "",
},
{
name: "insufficient scope",
header: "repo",