File tree Expand file tree Collapse file tree 3 files changed +38
-8
lines changed
Expand file tree Collapse file tree 3 files changed +38
-8
lines changed Original file line number Diff line number Diff line change 1- const defaultConfig = {
2- requestInfoReplyComment : 'The maintainers of this repository would appreciate it if you could provide more information.' ,
3- requestInfoOn : {
4- issue : true ,
5- pullRequest : true
6- }
7- }
1+ const getComment = require ( './lib/getComment' )
2+ const defaultConfig = require ( './lib/defaultConfig' )
83
94module . exports = robot => {
105 robot . on ( 'pull_request.opened' , receive )
@@ -35,7 +30,8 @@ module.exports = robot => {
3530 }
3631 }
3732 if ( ! body || badTitle ) {
38- context . github . issues . createComment ( context . issue ( { body : config . requestInfoReplyComment || defaultConfig . requestInfoReplyComment } ) )
33+ const comment = getComment ( config . requestInfoReplyComment , defaultConfig . requestInfoReplyComment )
34+ context . github . issues . createComment ( context . issue ( { body : comment } ) )
3935
4036 if ( config . requestInfoLabelToAdd ) {
4137 // Add label if there is one listed in the yaml file
Original file line number Diff line number Diff line change 1+ const defaultConfig = {
2+ requestInfoReplyComment : 'The maintainers of this repository would appreciate it if you could provide more information.' ,
3+ requestInfoOn : {
4+ issue : true ,
5+ pullRequest : true
6+ }
7+ }
8+
9+ module . exports = defaultConfig
Original file line number Diff line number Diff line change 1+ module . exports = getComment
2+
3+ function getComment ( comment , defaultComment ) {
4+ // comment can be either a string or an array
5+
6+ if ( ! comment ) {
7+ comment = defaultComment
8+ }
9+
10+ if ( typeof comment === 'string' || comment instanceof String ) {
11+ return comment
12+ } else {
13+ const pos = getRandomInt ( 0 , comment . length )
14+ return comment [ pos ] || defaultComment
15+ }
16+ }
17+
18+ function getRandomInt ( min , max ) {
19+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
20+ // The maximum is exclusive and the minimum is inclusive
21+
22+ min = Math . ceil ( min )
23+ max = Math . floor ( max )
24+ return Math . floor ( Math . random ( ) * ( max - min ) ) + min
25+ }
You can’t perform that action at this time.
0 commit comments