@@ -11,13 +11,6 @@ async function when_suspicious({ github, context, failed_checks }){
1111 // issue_number: issueNumber,
1212 // labels: ["suspicious"]
1313 // });
14- // await github.rest.issues.createComment({
15- // owner,
16- // repo,
17- // issue_number: issueNumber,
18- // body: "This issue/PR has been automatically closed as it does not meet our contribution guidelines. Please read our contribution guide before submitting."
19- // });
20-
2114
2215 const reasons = failed_checks . map ( check => `- ${ check . reason } ` ) . join ( "\n" ) ;
2316 const commentBody = `This issue/PR has been automatically flagged as [suspicious] as it might not meet contribution requirements.
@@ -29,6 +22,12 @@ ${reasons}
2922 ` ;
3023
3124 console . log ( ">>> DEBUG:\n" , commentBody ) ;
25+ // await github.rest.issues.createComment({
26+ // owner,
27+ // repo,
28+ // issue_number: issueNumber,
29+ // body: `${commentBody}`
30+ // });
3231
3332 // TODO: if too many or critical checks failed, then consider immediatly closing:
3433
@@ -56,21 +55,19 @@ class Check {
5655
5756module . exports = async ( { github, context, core } ) => {
5857
59- const { owner, repo } = context . repo ;
60- const { SHA } = process . env ;
61- const author = context . actor ;
62-
63- const { data : user } = await github . rest . users . getByUsername ( { username : author } ) ;
58+ // const {SHA} = process.env; // for octokit.rest.repos.getCommit
59+ const username = context . actor ;
60+ const { data : user } = await github . rest . users . getByUsername ( { username : username } ) ;
6461
6562 const isAuthorOnlyContributionOnGH = await ( async ( ) => {
6663 // WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
6764 const { data : events } = await github . rest . activity . listEventsForAuthenticatedUser ( {
68- username : author ,
65+ username : username ,
6966 per_page : 1
7067 } ) ;
7168
72- console . log ( ">>> is_author_only_contribution_on_GH : " , {
73- username : author ,
69+ console . log ( ">>> is_username_only_contribution_on_GH : " , {
70+ username : username ,
7471 events : events ,
7572 events_length : events . length ,
7673 result : events . length === 0 ,
@@ -86,23 +83,9 @@ module.exports = async ({ github, context, core }) => {
8683 return value ;
8784 } ) ( ) ;
8885 const create_at = new Date ( user . created_at ) ;
89-
90- console . log ( ">>> was_author_account_recently_created: " , {
91- time_point : time_point ,
92- create_at : create_at ,
93- result : create_at >= time_point
94- } ) ;
95-
9686 return create_at >= time_point ;
9787 } ) ( ) ;
9888
99- console . log ( ">>> " , {
100- followers : user . followers ,
101- following : user . following ,
102- public_repos : user . public_repos ,
103- public_gists : user . public_gists
104- } )
105-
10689 const checks = [
10790 new Check ( {
10891 predicate : ( ) => user . followers !== 0 && user . following !== 0 ,
@@ -126,9 +109,8 @@ module.exports = async ({ github, context, core }) => {
126109 const failed_checks = checks . filter ( check => ! check . pass ( ) ) ;
127110
128111 const threshold = 0 ;
129- console . log ( ">>> failed_checks amount: " , failed_checks . length , "vs. threshold: " , threshold )
130112 if ( failed_checks . length <= threshold )
131113 return ;
132114
133115 when_suspicious ( { github, context, failed_checks} ) ;
134- } ;
116+ } ;
0 commit comments