Skip to content

Commit

Permalink
refactor(push): use external invalid config file job creator
Browse files Browse the repository at this point in the history
  • Loading branch information
espy committed Apr 12, 2018
1 parent f626803 commit af0bf50
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions jobs/github-event/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
} = require('../../lib/branches-to-delete')
const getConfig = require('../../lib/get-config')
const { validate } = require('../../lib/validate-greenkeeper-json')
const { invalidConfigFile } = require('../../lib/invalid-config-file')

module.exports = async function (data) {
const { repositories } = await dbs()
Expand Down Expand Up @@ -198,27 +199,6 @@ module.exports = async function (data) {
log.success('success')
}

async function invalidConfigFile ({repoDoc, config, repositories, repository, repositoryId, details, log}) {
log.warn('validation of greenkeeper.json failed', {error: details, greenkeeperJson: repoDoc.greenkeeper})
// reset greenkeeper config in repoDoc to the previous working version and start an 'invalid-config-file' job
_.set(repoDoc, ['greenkeeper'], config)
await updateDoc(repositories, repository, repoDoc)
// If the config file is invalid, open an issue with validation errors and don’t do anything else in this file:
// - no initial branch should be created (?)
// - no initial subgroup branches should (or can be) be created
// - no branches need to be deleted (we can’t be sure the changes are valid)

return {
data: {
name: 'invalid-config-file',
messages: _.map(details, 'formattedMessage'),
errors: details,
repositoryId,
accountId: repoDoc.accountId
}
}
}

function updateDoc (repositories, repository, repoDoc) {
return repositories.put(
updatedAt(
Expand Down

0 comments on commit af0bf50

Please sign in to comment.