Skip to content

Commit

Permalink
refactor(metadata): deduplicate commits (element-plus#7879)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored May 24, 2022
1 parent 3d2a257 commit 87bc353
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/metadata/src/contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,6 +29,7 @@ interface ApiResult {
endCursor: string
}
nodes: Array<{
oid: string
author: {
avatarUrl: string
date: string
Expand Down Expand Up @@ -69,6 +70,7 @@ const fetchCommits = async (
after ? `, after: "${after}"` : ''
}) {
nodes {
oid
author {
avatarUrl
date
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 87bc353

Please sign in to comment.