Skip to content

Commit

Permalink
fix: add missing noop param for full-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
PendaGTP committed Jan 7, 2025
1 parent ee5909a commit fd14365
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
33 changes: 21 additions & 12 deletions full-sync.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
const { createProbot } = require('probot')
const appFn = require('./')
const { FULL_SYNC_NOOP } = require('./lib/env')
const { createProbot } = require('probot')

async function performFullSync (appFn, noop) {
const probot = createProbot()
probot.log.info(`Starting full sync with NOOP=${noop}`)

const probot = createProbot()
probot.log.info('Starting full sync.')
const app = appFn(probot, {})
app.syncInstallation()
.then(settings => {
if (settings.errors.length > 0) {
try {
const app = appFn(probot, {})
const settings = await app.syncInstallation(noop)

if (settings.errors && settings.errors.length > 0) {
probot.log.error('Errors occurred during full sync.')
process.exit(1)
} else {
probot.log.info('Done with full sync.')
}
})
.catch(error => {

probot.log.info('Full sync completed successfully.')
} catch (error) {
process.stdout.write(`Unexpected error during full sync: ${error}\n`)
process.exit(1)
})
}
}

performFullSync(appFn, FULL_SYNC_NOOP).catch((error) => {
console.error('Fatal error during full sync:', error)
process.exit(1)
})
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
}
}

async function syncInstallation () {
async function syncInstallation (noop = false) {
robot.log.trace('Fetching installations')
const github = await robot.auth()

Expand All @@ -249,7 +249,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
log: robot.log,
repo: () => { return { repo: env.ADMIN_REPO, owner: installation.account.login } }
}
return syncAllSettings(false, context)
return syncAllSettings(noop, context)
}
return null
}
Expand Down
3 changes: 2 additions & 1 deletion lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {
DEPLOYMENT_CONFIG_FILE: process.env.DEPLOYMENT_CONFIG_FILE || 'deployment-settings.yml',
CREATE_PR_COMMENT: process.env.CREATE_PR_COMMENT || 'true',
CREATE_ERROR_ISSUE: process.env.CREATE_ERROR_ISSUE || 'true',
BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false'
BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false',
FULL_SYNC_NOOP: process.env.FULL_SYNC_NOOP === 'true'
}

0 comments on commit fd14365

Please sign in to comment.