Skip to content

Commit

Permalink
fix: dedupe contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 15, 2022
1 parent 0be663c commit a911feb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,24 @@ export async function getContributors(commits: GitCommit[], options: ChangelogOp
})
const authors = Array.from(map.values())
const resolved = await Promise.all(authors.map(info => resolveAuthorInfo(options, info)))
return resolved.sort((a, b) => (a.login || a.name).localeCompare(b.login || b.name))

const loginSet = new Set<string>()
const nameSet = new Set<string>()
return resolved
.sort((a, b) => (a.login || a.name).localeCompare(b.login || b.name))
.filter((i) => {
if (i.login && loginSet.has(i.login))
return false
if (i.login) {
loginSet.add(i.login)
}
else {
if (nameSet.has(i.name))
return false
nameSet.add(i.name)
}
return true
})
}

export async function hasTagOnGitHub(tag: string, options: ChangelogOptions) {
Expand Down

0 comments on commit a911feb

Please sign in to comment.