Api refactor, return object for getAllTags
Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
@@ -457,13 +457,15 @@ export class GitReleaseApiClient implements GitReleaseApi {
|
||||
...DISABLE_CACHE,
|
||||
});
|
||||
|
||||
return tags
|
||||
.map(tag => ({
|
||||
tagName: tag.ref.replace('refs/tags/', ''),
|
||||
tagSha: tag.object.sha,
|
||||
tagType: tag.object.type as 'tag' | 'commit',
|
||||
}))
|
||||
.reverse();
|
||||
return {
|
||||
tags: tags
|
||||
.map(tag => ({
|
||||
tagName: tag.ref.replace('refs/tags/', ''),
|
||||
tagSha: tag.object.sha,
|
||||
tagType: tag.object.type as 'tag' | 'commit',
|
||||
}))
|
||||
.reverse(),
|
||||
};
|
||||
};
|
||||
|
||||
getAllReleases: GitReleaseApi['getAllReleases'] = async ({ owner, repo }) => {
|
||||
@@ -728,13 +730,13 @@ export interface GitReleaseApi {
|
||||
*/
|
||||
getAllTags: (
|
||||
args: OwnerRepo,
|
||||
) => Promise<
|
||||
Array<{
|
||||
) => Promise<{
|
||||
tags: Array<{
|
||||
tagName: string;
|
||||
tagSha: string;
|
||||
tagType: 'tag' | 'commit';
|
||||
}>
|
||||
>;
|
||||
}>;
|
||||
}>;
|
||||
|
||||
getAllReleases: (
|
||||
args: OwnerRepo,
|
||||
|
||||
@@ -25,7 +25,7 @@ export function getReleaseStats({
|
||||
project,
|
||||
mappedReleases,
|
||||
}: {
|
||||
allTags: GetAllTagsResult;
|
||||
allTags: GetAllTagsResult['tags'];
|
||||
project: Project;
|
||||
mappedReleases: ReleaseStats;
|
||||
}) {
|
||||
|
||||
@@ -25,7 +25,7 @@ export const useGetStats = () => {
|
||||
const { project } = useProjectContext();
|
||||
|
||||
const stats = useAsync(async () => {
|
||||
const [allReleases, allTags] = await Promise.all([
|
||||
const [allReleases, { tags: allTags }] = await Promise.all([
|
||||
pluginApiClient.getAllReleases({
|
||||
owner: project.owner,
|
||||
repo: project.repo,
|
||||
|
||||
@@ -293,13 +293,15 @@ export const mockApiClient: GitReleaseApi = {
|
||||
},
|
||||
})),
|
||||
|
||||
getAllTags: jest.fn(async () => [
|
||||
{
|
||||
tagName: MOCK_RELEASE_CANDIDATE_TAG_NAME_CALVER,
|
||||
tagSha: 'mock_sha',
|
||||
tagType: 'tag' as const,
|
||||
},
|
||||
]),
|
||||
getAllTags: jest.fn(async () => ({
|
||||
tags: [
|
||||
{
|
||||
tagName: MOCK_RELEASE_CANDIDATE_TAG_NAME_CALVER,
|
||||
tagSha: 'mock_sha',
|
||||
tagType: 'tag' as const,
|
||||
},
|
||||
],
|
||||
})),
|
||||
|
||||
getAllReleases: jest.fn(async () => [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user