@@ -88,11 +88,17 @@ async function run({ github, context }) {
88
88
89
89
const username = context . actor ;
90
90
const { data : user } = await github . rest . users . getByUsername ( { username : username } ) ;
91
+
91
92
const payload = context . payload ;
92
- const title = payload . issue ?. title || payload . pull_request ?. title || "" ;
93
- const body = payload . issue ?. body || payload . pull_request ?. body || "" ;
94
93
95
- console . log ( 'Checking' , { user : username , title : title } )
94
+ const issue_or_pr = ( ( ) => {
95
+ if ( payload . issue ) return payload . issue ;
96
+ if ( payload . pull_request ) return payload . pull_request ;
97
+ throw new Error ( "Only supports issues and PRs" )
98
+ } ) ( ) ;
99
+
100
+
101
+ console . log ( 'Checking' , { user : username , title : issue_or_pr . title } )
96
102
97
103
const isAuthorOnlyContributionOnGH = await ( async ( ) => {
98
104
// WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
@@ -105,7 +111,7 @@ async function run({ github, context }) {
105
111
const WasAuthorRecentlyCreated = ( ( ) => {
106
112
107
113
const time_point = ( ( ) => {
108
- let value = new Date ( ) ;
114
+ let value = Date . parse ( issue_or_pr . created_at ) ; // new Date();
109
115
value . setHours ( value . getHours ( ) - 2 ) ;
110
116
return value ;
111
117
} ) ( ) ;
@@ -118,8 +124,8 @@ async function run({ github, context }) {
118
124
return false ;
119
125
120
126
const threshold = 20 ;
121
- return title . length < threshold
122
- || body . length < threshold ;
127
+ return issue_or_pr . length < threshold
128
+ || issue_or_pr . length < threshold ;
123
129
} ) ( ) ;
124
130
125
131
const checks = [
@@ -226,6 +232,7 @@ class Testing {
226
232
const payload_content = {
227
233
title : response . data . title ,
228
234
body : response . data . body ,
235
+ created_at : new Date ( ) // now
229
236
} ;
230
237
return {
231
238
actor : response . data . user . login ,
0 commit comments