From 7b06b68dbd4eb262d8538720ae8410f55d76a363 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Sun, 4 Aug 2024 21:16:03 -0400 Subject: [PATCH] add support for github current user --- platforms/github/client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platforms/github/client.go b/platforms/github/client.go index 2cf4d1e..e7f1285 100644 --- a/platforms/github/client.go +++ b/platforms/github/client.go @@ -1,6 +1,7 @@ package github import ( + "context" "fmt" "log/slog" "sync" @@ -47,6 +48,14 @@ func NewClient(logger *slog.Logger, config config.GithubClientConfig) (*githubCl userCache: map[int64]*User{}, } + // Fetch current user and add it to the list + currentUser, _, err := client.Users.Get(context.Background(), "") + if err != nil { + logger.Warn("failed to fetch the current user:", "error", err.Error()) + } else { + gitHubClient.UserNames = append(gitHubClient.UserNames, *currentUser.Login) + } + return gitHubClient, nil } @@ -71,7 +80,6 @@ func (c *githubClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e rootContent[user.Name] = user } } - // TODO: user + current user c.rootContent = rootContent }