Skip to content

Commit

Permalink
fix(reset): don't fail if branch does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Realtin committed Aug 1, 2017
1 parent 906db1e commit f7e2b84
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobs/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ module.exports = async function ({ repositoryFullName }) {
ref: `heads/${branch.head}`
}))
} catch (e) {
if (e.code === 404) {
continue
}
if (branch.head === 'greenkeeper/initial' || branch.head === 'greenkeeper-initial') {
throw e
}
Expand Down
26 changes: 26 additions & 0 deletions test/jobs/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,32 @@ test('reset repo', async t => {
}
})

t.test('do not mind if a branch does not exist', async t => {
await repositories.put({
_id: '42:branch:deadbeef0',
type: 'branch',
repositoryId: '42',
head: 'greenkeeper/initial'
})
githubNock
.delete('/repos/finnp/abc/git/refs/heads/greenkeeper-standard-10.0.0')
.reply(200)
.delete('/repos/finnp/abc/git/refs/heads/greenkeeper/initial')
.reply(404)
.get('/repos/finnp/abc')
.reply(200, githubRepository)

try {
await worker({
repositoryFullName: 'finnp/abc'
})
} catch (e) {
t.fail('error thrown')
} finally {
await waitFor(timeToWaitAfterTests)
}
})

t.test('delete all branchdocs of the repo', async t => {
t.plan(1)
githubNock
Expand Down

0 comments on commit f7e2b84

Please sign in to comment.