diff --git a/lib/git/hooks/webhook.js b/lib/git/hooks/webhook.js index bcdb29a..a74e4e4 100644 --- a/lib/git/hooks/webhook.js +++ b/lib/git/hooks/webhook.js @@ -187,15 +187,8 @@ exports.bitbucket = { type: 'bitbucket', isValid: function(req) { - - if (req && req.body && req.body.payload) { - try { - req.body = JSON.parse(req.body.payload); - return req.body && req.body.commits && req.body.commits.length; - /* istanbul ignore next */ - } catch(e) { - // We don't care about a busted message. - } + if (req && req.body && req.body.changes && req.body.eventKey && req.body.eventKey === "repo:refs_changed") { + return req.body && req.body.changes && req.body.changes.length; } return false; @@ -203,15 +196,13 @@ exports.bitbucket = { getHeadChanges: function(req) { var changes = []; - for (var i=0; i