From 9cecdf8f95fe613787f3a697dbd6ead54db0c00b Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Fri, 12 Jul 2024 11:03:29 +0100 Subject: [PATCH] fix: fetch GitHub PR author name, fixes #7232 Reverts the change to `getPullRequestAuthor` in the GitHub backend from 4f419dd, so that it fetches the PR author's name as before. In the AWS Cognito GitHub backend, return the GitHub login as the PR author. --- .../src/implementation.tsx | 5 +++++ packages/decap-cms-backend-github/src/API.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/decap-cms-backend-aws-cognito-github-proxy/src/implementation.tsx b/packages/decap-cms-backend-aws-cognito-github-proxy/src/implementation.tsx index e7bc6de432b8..61969986c751 100644 --- a/packages/decap-cms-backend-aws-cognito-github-proxy/src/implementation.tsx +++ b/packages/decap-cms-backend-aws-cognito-github-proxy/src/implementation.tsx @@ -5,6 +5,7 @@ import AuthenticationPage from './AuthenticationPage'; import type { GitHubUser } from 'decap-cms-backend-github/src/implementation'; import type { Config } from 'decap-cms-lib-util/src'; +import type { Octokit } from '@octokit/rest'; export default class AwsCognitoGitHubProxyBackend extends GitHubBackend { constructor(config: Config, options = {}) { @@ -44,4 +45,8 @@ export default class AwsCognitoGitHubProxyBackend extends GitHubBackend { } return this._currentUserPromise; } + + async getPullRequestAuthor(pullRequest: Octokit.PullsListResponseItem) { + return pullRequest.user?.login; + } } diff --git a/packages/decap-cms-backend-github/src/API.ts b/packages/decap-cms-backend-github/src/API.ts index a044342c5fca..244a3e228509 100644 --- a/packages/decap-cms-backend-github/src/API.ts +++ b/packages/decap-cms-backend-github/src/API.ts @@ -580,7 +580,7 @@ export default class API { } try { - const user = await this.user(); + const user: GitHubUser = await this.request(`/users/${pullRequest.user.login}`); return user.name || user.login; } catch { return;