From 3be12308ca8cfaff43282decc22bcad9d16ccbd5 Mon Sep 17 00:00:00 2001 From: 6d7a <56823591+6d7a@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:41:20 +0200 Subject: [PATCH] fix: allow unauthenticated (#96) * fix: use unauthenticated client if no token provided * docs: add note about rate limits --- cmd/client.go | 6 +++++- cmd/root.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/client.go b/cmd/client.go index c611282..ed775fb 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -11,7 +11,11 @@ func newClient(ctx context.Context, token, baseURL string) (*github.Client, erro ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) if baseURL == "" { - return github.NewClient(oauth2.NewClient(ctx, ts)), nil + if token == "" { + return github.NewClient(nil), nil + } else { + return github.NewClient(oauth2.NewClient(ctx, ts)), nil + } } return github.NewEnterpriseClient(baseURL, "", oauth2.NewClient(ctx, ts)) diff --git a/cmd/root.go b/cmd/root.go index 76b8a7e..1d8fb4c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -65,6 +65,7 @@ Finally, it prints a rank by each category. Important notes: +* GitHub's API rate limits for unauthenticated requests have been lowered significantly in the recent past. Using the ` + "`--token`" + ` option for compiling stats will speed up gathering of data considerably, since for authenticated requests it will be less likely that rate-limiting timelocks have to be awaited. * The ` + "`--since`" + ` filter does not work "that well" because GitHub summarizes thedata by week, so the data is not as granular as it should be. * The ` + "`--include-reviews`" + ` only grabs reviews from users that had contributions on the previous step. * In the ` + "`--blacklist`" + ` option, 'foo' blacklists both the 'foo' user and 'foo' repo, while 'user:foo' blacklists only the user and 'repo:foo' only the repository.