@@ -13,8 +13,7 @@ type Contribution = {
13
13
count : number
14
14
}
15
15
16
- const buildWeights = ( contributors : any ) : Map < string , number > => {
17
- console . info ( contributors )
16
+ const buildWeights = ( contributorStats : any [ ] ) : Map < string , number > => {
18
17
const loginToTotalWeight : Map < string , number > = new Map < string , number > ( )
19
18
20
19
const addContributions = ( weight : number , contributions : Contribution [ ] , onlyExisting : boolean ) => {
@@ -26,15 +25,19 @@ const buildWeights = (contributors: any): Map<string, number> => {
26
25
}
27
26
}
28
27
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
+ }
32
33
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
+ }
38
41
39
42
return loginToTotalWeight
40
43
}
@@ -93,16 +96,21 @@ const buildCoreTeamInfo = async (): Promise<ContributorInfo[]> => {
93
96
94
97
const main = async ( ) => {
95
98
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 )
106
114
const weightedContributors : WeightedContributor [ ] = [ ]
107
115
loginToWeight . forEach ( ( weight , login ) => weightedContributors . push ( { login, weight } ) )
108
116
0 commit comments