diff --git a/plugins/git-release-manager/src/api/GitReleaseApiClient.ts b/plugins/git-release-manager/src/api/GitReleaseApiClient.ts index b1c2b5b5ac..0de2893fd9 100644 --- a/plugins/git-release-manager/src/api/GitReleaseApiClient.ts +++ b/plugins/git-release-manager/src/api/GitReleaseApiClient.ts @@ -213,12 +213,14 @@ export class GitReleaseApiClient implements GitReleaseApi { }); return { - sha: latestCommit.sha, - htmlUrl: latestCommit.html_url, commit: { - message: latestCommit.commit.message, + sha: latestCommit.sha, + htmlUrl: latestCommit.html_url, + commit: { + message: latestCommit.commit.message, + }, + createdAt: latestCommit.commit.committer?.date, }, - createdAt: latestCommit.commit.committer?.date, }; }; @@ -568,12 +570,14 @@ export interface GitReleaseApi { ref: string; } & OwnerRepo, ) => Promise<{ - sha: string; - htmlUrl: string; commit: { - message: string; + sha: string; + htmlUrl: string; + commit: { + message: string; + }; + createdAt?: string; }; - createdAt?: string; }>; getBranch: ( diff --git a/plugins/git-release-manager/src/features/CreateReleaseCandidate/hooks/useCreateReleaseCandidate.ts b/plugins/git-release-manager/src/features/CreateReleaseCandidate/hooks/useCreateReleaseCandidate.ts index af07bfe3c9..49acf13aa3 100644 --- a/plugins/git-release-manager/src/features/CreateReleaseCandidate/hooks/useCreateReleaseCandidate.ts +++ b/plugins/git-release-manager/src/features/CreateReleaseCandidate/hooks/useCreateReleaseCandidate.ts @@ -70,7 +70,7 @@ export function useCreateReleaseCandidate({ * (1) Get the default branch's most recent commit */ const [latestCommitRes, run] = useAsyncFn(async () => { - const latestCommit = await pluginApiClient + const { commit: latestCommit } = await pluginApiClient .getCommit({ owner: project.owner, repo: project.repo, diff --git a/plugins/git-release-manager/src/features/PromoteRc/hooks/usePromoteRc.ts b/plugins/git-release-manager/src/features/PromoteRc/hooks/usePromoteRc.ts index 7980b38ed8..ff164dc5eb 100644 --- a/plugins/git-release-manager/src/features/PromoteRc/hooks/usePromoteRc.ts +++ b/plugins/git-release-manager/src/features/PromoteRc/hooks/usePromoteRc.ts @@ -52,7 +52,7 @@ export function usePromoteRc({ * (1) Fetch most recent release branch commit */ const [latestReleaseBranchCommitSha, run] = useAsyncFn(async () => { - const latestCommit = await pluginApiClient + const { commit: latestCommit } = await pluginApiClient .getCommit({ owner: project.owner, repo: project.repo, diff --git a/plugins/git-release-manager/src/features/Stats/helpers/getTagDates.ts b/plugins/git-release-manager/src/features/Stats/helpers/getTagDates.ts index f69d853ae7..ce76eccc54 100644 --- a/plugins/git-release-manager/src/features/Stats/helpers/getTagDates.ts +++ b/plugins/git-release-manager/src/features/Stats/helpers/getTagDates.ts @@ -58,10 +58,7 @@ export const getTagDates = async ({ } if (startTag.tagType === 'commit' && endTag.tagType === 'commit') { - const [ - { createdAt: startDate }, - { createdAt: endDate }, - ] = await Promise.all([ + const [{ commit: startCommit }, { commit: endCommit }] = await Promise.all([ pluginApiClient.getCommit({ owner: project.owner, repo: project.repo, @@ -75,13 +72,13 @@ export const getTagDates = async ({ ]); return { - startDate, - endDate, + startDate: startCommit.createdAt, + endDate: endCommit.createdAt, }; } if (startTag.tagType === 'tag' && endTag.tagType === 'commit') { - const [{ date: startDate }, { createdAt: endDate }] = await Promise.all([ + const [{ date: startDate }, { commit: endCommit }] = await Promise.all([ getCommitFromTag({ pluginApiClient, project, tag: startTag }), pluginApiClient.getCommit({ owner: project.owner, @@ -92,12 +89,12 @@ export const getTagDates = async ({ return { startDate, - endDate, + endDate: endCommit.createdAt, }; } if (startTag.tagType === 'commit' && endTag.tagType === 'tag') { - const [{ createdAt: startDate }, { date: endDate }] = await Promise.all([ + const [{ commit: startCommit }, { date: endDate }] = await Promise.all([ pluginApiClient.getCommit({ owner: project.owner, repo: project.repo, @@ -107,7 +104,7 @@ export const getTagDates = async ({ ]); return { - startDate, + startDate: startCommit.createdAt, endDate, }; } @@ -131,7 +128,7 @@ async function getCommitFromTag({ repo: project.repo, tagSha: tag.tagSha, }); - const startCommit = await pluginApiClient.getCommit({ + const { commit: startCommit } = await pluginApiClient.getCommit({ owner: project.owner, repo: project.repo, ref: singleTag.objectSha, diff --git a/plugins/git-release-manager/src/test-helpers/test-helpers.ts b/plugins/git-release-manager/src/test-helpers/test-helpers.ts index fc6e09ff0c..b89e6a65d5 100644 --- a/plugins/git-release-manager/src/test-helpers/test-helpers.ts +++ b/plugins/git-release-manager/src/test-helpers/test-helpers.ts @@ -218,12 +218,14 @@ export const mockApiClient: GitReleaseApi = { })), getCommit: jest.fn(async () => ({ - sha: 'latestCommit.sha', - htmlUrl: 'latestCommit.html_url', commit: { - message: 'latestCommit.commit.message', + sha: 'latestCommit.sha', + htmlUrl: 'latestCommit.html_url', + commit: { + message: 'latestCommit.commit.message', + }, + createdAt: '2021-01-01T10:11:12Z', }, - createdAt: '2021-01-01T10:11:12Z', })), getBranch: jest.fn(async () => ({