@@ -13,7 +13,7 @@ let deploymentConfig
13
13
module . exports = ( robot , { getRouter } , Settings = require ( './lib/settings' ) ) => {
14
14
let appName = 'safe-settings'
15
15
let appSlug = 'safe-settings'
16
- async function syncAllSettings ( nop , context , repo = context . repo ( ) , ref ) {
16
+ async function syncAllSettings ( nop , context , repo = context . repo ( ) , ref ) {
17
17
try {
18
18
deploymentConfig = await loadYamlFileSystem ( )
19
19
robot . log . debug ( `deploymentConfig is ${ JSON . stringify ( deploymentConfig ) } ` )
@@ -42,7 +42,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
42
42
}
43
43
}
44
44
45
- async function syncSubOrgSettings ( nop , context , suborg , repo = context . repo ( ) , ref ) {
45
+ async function syncSubOrgSettings ( nop , context , suborg , repo = context . repo ( ) , ref ) {
46
46
try {
47
47
deploymentConfig = await loadYamlFileSystem ( )
48
48
robot . log . debug ( `deploymentConfig is ${ JSON . stringify ( deploymentConfig ) } ` )
@@ -67,7 +67,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
67
67
}
68
68
}
69
69
70
- async function syncSettings ( nop , context , repo = context . repo ( ) , ref ) {
70
+ async function syncSettings ( nop , context , repo = context . repo ( ) , ref ) {
71
71
try {
72
72
deploymentConfig = await loadYamlFileSystem ( )
73
73
robot . log . debug ( `deploymentConfig is ${ JSON . stringify ( deploymentConfig ) } ` )
@@ -92,7 +92,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
92
92
}
93
93
}
94
94
95
- async function renameSync ( nop , context , repo = context . repo ( ) , rename , ref ) {
95
+ async function renameSync ( nop , context , repo = context . repo ( ) , rename , ref ) {
96
96
try {
97
97
deploymentConfig = await loadYamlFileSystem ( )
98
98
robot . log . debug ( `deploymentConfig is ${ JSON . stringify ( deploymentConfig ) } ` )
@@ -101,7 +101,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
101
101
const config = Object . assign ( { } , deploymentConfig , runtimeConfig )
102
102
const renameConfig = Object . assign ( { } , config , rename )
103
103
robot . log . debug ( `config for ref ${ ref } is ${ JSON . stringify ( config ) } ` )
104
- return Settings . sync ( nop , context , repo , renameConfig , ref )
104
+ return Settings . sync ( nop , context , repo , renameConfig , ref )
105
105
} catch ( e ) {
106
106
if ( nop ) {
107
107
let filename = env . SETTINGS_FILE_PATH
@@ -123,7 +123,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
123
123
*
124
124
* @return The parsed YAML file
125
125
*/
126
- async function loadYamlFileSystem ( ) {
126
+ async function loadYamlFileSystem ( ) {
127
127
if ( deploymentConfig === undefined ) {
128
128
const deploymentConfigPath = env . DEPLOYMENT_CONFIG_FILE
129
129
if ( fs . existsSync ( deploymentConfigPath ) ) {
@@ -135,7 +135,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
135
135
return deploymentConfig
136
136
}
137
137
138
- function getAllChangedSubOrgConfigs ( payload ) {
138
+ function getAllChangedSubOrgConfigs ( payload ) {
139
139
const settingPattern = new Glob ( `${ env . CONFIG_PATH } /suborgs/*.yml` )
140
140
// Changes will be an array of files that were added
141
141
const added = payload . commits . map ( c => {
@@ -159,7 +159,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
159
159
return configs
160
160
}
161
161
162
- function getAllChangedRepoConfigs ( payload , owner ) {
162
+ function getAllChangedRepoConfigs ( payload , owner ) {
163
163
const settingPattern = new Glob ( `${ env . CONFIG_PATH } /repos/*.yml` )
164
164
// Changes will be an array of files that were added
165
165
const added = payload . commits . map ( c => {
@@ -182,7 +182,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
182
182
return configs
183
183
}
184
184
185
- function getChangedRepoConfigName ( glob , files , owner ) {
185
+ function getChangedRepoConfigName ( glob , files , owner ) {
186
186
const modifiedFiles = files . filter ( s => {
187
187
robot . log . debug ( JSON . stringify ( s ) )
188
188
return ( s . search ( glob ) >= 0 )
@@ -193,7 +193,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
193
193
} )
194
194
}
195
195
196
- function getChangedSubOrgConfigName ( glob , files ) {
196
+ function getChangedSubOrgConfigName ( glob , files ) {
197
197
const modifiedFiles = files . filter ( s => {
198
198
robot . log . debug ( JSON . stringify ( s ) )
199
199
return ( s . search ( glob ) >= 0 )
@@ -205,7 +205,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
205
205
} )
206
206
}
207
207
208
- async function createCheckRun ( context , pull_request , head_sha , head_branch ) {
208
+ async function createCheckRun ( context , pull_request , head_sha , head_branch ) {
209
209
const { payload } = context
210
210
// robot.log.debug(`Check suite was requested! for ${context.repo()} ${pull_request.number} ${head_sha} ${head_branch}`)
211
211
const res = await context . octokit . checks . create ( {
@@ -234,7 +234,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
234
234
}
235
235
236
236
237
- async function syncInstallation ( ) {
237
+ async function syncInstallation ( ) {
238
238
robot . log . trace ( 'Fetching installations' )
239
239
const github = await robot . auth ( )
240
240
@@ -395,7 +395,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
395
395
} )
396
396
397
397
robot . on ( 'repository.renamed' , async context => {
398
- if ( env . BLOCK_REPO_RENAME_BY_HUMAN !== 'true' ) {
398
+ if ( env . BLOCK_REPO_RENAME_BY_HUMAN !== 'true' ) {
399
399
robot . log . debug ( `"env.BLOCK_REPO_RENAME_BY_HUMAN" is 'false' by default. Repo rename is not managed by Safe-settings. Continue with the default behavior.` )
400
400
return
401
401
}
@@ -414,7 +414,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
414
414
const newPath = `.github/repos/${ payload . repository . name } .yml`
415
415
robot . log . debug ( oldPath )
416
416
try {
417
- const repofile = await context . octokit . request ( 'GET /repos/{owner}/{repo}/contents/{path}' , {
417
+ const repofile = await context . octokit . request ( 'GET /repos/{owner}/{repo}/contents/{path}' , {
418
418
owner : payload . repository . owner . login ,
419
419
repo : env . ADMIN_REPO ,
420
420
path : oldPath ,
@@ -443,7 +443,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
443
443
owner : payload . repository . owner . login ,
444
444
repo : env . ADMIN_REPO ,
445
445
path : newPath ,
446
- name : `${ payload . repository . name } .yml` ,
446
+ name : `${ payload . repository . name } .yml` ,
447
447
content : content ,
448
448
message : `Repo Renamed and safe-settings renamed the file from ${ payload . changes . repository . name . from } to ${ payload . repository . name } ` ,
449
449
sha : repofile . data . sha ,
@@ -455,21 +455,21 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
455
455
} else {
456
456
robot . log . error ( error )
457
457
}
458
- }
458
+ }
459
459
460
460
} catch ( error ) {
461
461
if ( error . status === 404 ) {
462
462
//nop
463
- } else {
463
+ } else {
464
464
robot . log . error ( error )
465
465
}
466
- }
466
+ }
467
467
return
468
468
} else {
469
469
robot . log . debug ( 'Repository Edited by a Human' )
470
470
// Create a repository config to reset the name back to the previous name
471
- const rename = { repository : { name : payload . changes . repository . name . from , oldname : payload . repository . name } }
472
- const repo = { repo : payload . changes . repository . name . from , owner : payload . repository . owner . login }
471
+ const rename = { repository : { name : payload . changes . repository . name . from , oldname : payload . repository . name } }
472
+ const repo = { repo : payload . changes . repository . name . from , owner : payload . repository . owner . login }
473
473
return renameSync ( false , context , repo , rename )
474
474
}
475
475
} )
@@ -663,7 +663,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
663
663
syncInstallation ( )
664
664
} )
665
665
}
666
-
666
+
667
667
// Get info about the app
668
668
info ( )
669
669
0 commit comments