Skip to content

Commit 57e4203

Browse files
committed
dev: update contributors list
Take into account contributions in golancgi-lint-action. Run `cd .github/contributors && npm run all`
1 parent 922071f commit 57e4203

File tree

2 files changed

+66
-54
lines changed

2 files changed

+66
-54
lines changed

.github/contributors/generate.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ type Contribution = {
1313
count: number
1414
}
1515

16-
const buildWeights = (contributors: any): Map<string, number> => {
17-
console.info(contributors)
16+
const buildWeights = (contributorStats: any[]): Map<string, number> => {
1817
const loginToTotalWeight: Map<string, number> = new Map<string, number>()
1918

2019
const addContributions = (weight: number, contributions: Contribution[], onlyExisting: boolean) => {
@@ -26,15 +25,19 @@ const buildWeights = (contributors: any): Map<string, number> => {
2625
}
2726
}
2827

29-
// totally every pull or commit should account as 10
30-
addContributions(5, contributors.prCreators, false)
31-
addContributions(5, contributors.commitAuthors, false) // some commits are out pull requests
28+
for (const stat of contributorStats) {
29+
// totally every pull or commit should account as 10
30+
addContributions(5, stat.prCreators, false)
31+
addContributions(5, stat.commitAuthors, false) // some commits are out pull requests
32+
}
3233

33-
addContributions(2, contributors.prCommentators, true)
34-
addContributions(2, contributors.issueCreators, true)
35-
addContributions(2, contributors.issueCommentators, true)
36-
addContributions(2, contributors.reviewers, true)
37-
addContributions(0.3, contributors.reactors, true)
34+
for (const stat of contributorStats) {
35+
addContributions(2, stat.prCommentators, true)
36+
addContributions(2, stat.issueCreators, true)
37+
addContributions(2, stat.issueCommentators, true)
38+
addContributions(2, stat.reviewers, true)
39+
addContributions(0.3, stat.reactors, true)
40+
}
3841

3942
return loginToTotalWeight
4043
}
@@ -93,16 +96,21 @@ const buildCoreTeamInfo = async (): Promise<ContributorInfo[]> => {
9396

9497
const main = async () => {
9598
try {
96-
const contributors = await nyc.repoContributors({
97-
token: process.env.GITHUB_TOKEN,
98-
user: "golangci",
99-
repo: "golangci-lint",
100-
before: new Date(),
101-
after: new Date(0),
102-
commits: true,
103-
reactions: true,
104-
})
105-
const loginToWeight = buildWeights(contributors)
99+
const repos = [`golangci-lint`, `golangci-lint-action`]
100+
const promises = repos.map((repo) =>
101+
nyc.repoContributors({
102+
token: process.env.GITHUB_TOKEN,
103+
user: `golangci`,
104+
repo,
105+
before: new Date(),
106+
after: new Date(0),
107+
commits: true,
108+
reactions: true,
109+
})
110+
)
111+
const contributorStats = await Promise.all(promises)
112+
console.info(`Got stat for repos ${repos}`)
113+
const loginToWeight = buildWeights(contributorStats)
106114
const weightedContributors: WeightedContributor[] = []
107115
loginToWeight.forEach((weight, login) => weightedContributors.push({ login, weight }))
108116

0 commit comments

Comments
 (0)