Skip to content

Commit

Permalink
fix(reset): ignore 422 errors as that means the branch is already del…
Browse files Browse the repository at this point in the history
…eted anyway
  • Loading branch information
rmehner committed Aug 1, 2017
1 parent 02b661f commit 96c0366
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion jobs/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ module.exports = async function ({ repositoryFullName }) {
ref: `heads/${branch.head}`
}))
} catch (e) {
if (e.code === 422 && e.message === 'Reference does not exist') {
// branch was deleted already and since we wanted to delete it anyway, we're cool
// with this error
if (e.code === 422) {
continue
}
if (branch.head === 'greenkeeper/initial' || branch.head === 'greenkeeper-initial') {
Expand Down
2 changes: 1 addition & 1 deletion test/jobs/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test('reset repo', async t => {
.delete('/repos/finnp/abc/git/refs/heads/greenkeeper-standard-10.0.0')
.reply(200)
.delete('/repos/finnp/abc/git/refs/heads/greenkeeper/initial')
.reply(422, 'Reference does not exist')
.reply(422)
.get('/repos/finnp/abc')
.reply(200, githubRepository)

Expand Down

0 comments on commit 96c0366

Please sign in to comment.