refactor(metadata): deduplicate commits (#7879)

This commit is contained in:
三咲智子 2022-05-24 20:27:59 +08:00 committed by GitHub
parent 3d2a257101
commit 87bc35371c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import glob from 'fast-glob'
import { Octokit } from 'octokit'
import consola from 'consola'
import chalk from 'chalk'
import { chunk, mapValues } from 'lodash-es'
import { chunk, mapValues, uniqBy } from 'lodash-es'
import {
ensureDir,
errorAndExit,
@ -29,6 +29,7 @@ interface ApiResult {
endCursor: string
}
nodes: Array<{
oid: string
author: {
avatarUrl: string
date: string
@ -69,6 +70,7 @@ const fetchCommits = async (
after ? `, after: "${after}"` : ''
}) {
nodes {
oid
author {
avatarUrl
date
@ -145,7 +147,9 @@ const getContributorsByComponents = async (components: string[]) => {
.filter((option) => !!option.after)
} while (options.length > 0)
return mapValues(commits, (commits) => calcContributors(commits))
return mapValues(commits, (commits) =>
calcContributors(uniqBy(commits, 'oid'))
)
}
async function getContributors() {