From 0be2033d51185edacfe524e217c29ed44f92fc76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 15 Feb 2021 17:52:41 +0100 Subject: [PATCH] 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`. --- api/client.go | 2 +- api/client_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/client.go b/api/client.go index 09195181b..10e43c72b 100644 --- a/api/client.go +++ b/api/client.go @@ -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") } diff --git a/api/client_test.go b/api/client_test.go index 8edf279ea..caaf32a9f 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -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",