diff --git a/lib/git/hooks/webhook.js b/lib/git/hooks/webhook.js index bcdb29a..48792c6 100644 --- a/lib/git/hooks/webhook.js +++ b/lib/git/hooks/webhook.js @@ -7,6 +7,8 @@ var logger = require('../../logging.js'); var Branch = require('../branch.js'); var git_commands = require('../commands.js'); +var sha512 = require('sha512'); + // Create an object to map from host port to app. Multiple hosts can be configured to listen // on the same port. var server_apps = {}; @@ -77,6 +79,7 @@ function init_express(config) { // object to perform Git or Stash-specific functions. function create_webhook(config, repo, implementation) { var app = init_express(config); + var messageSend = 'ok'; // We don't care what method is used, so use them all. ['get','post','put','delete'].forEach(function(verb) { @@ -85,40 +88,43 @@ function create_webhook(config, repo, implementation) { /* istanbul ignore else */ if (implementation.isValid(req)) { - - logger.trace(util.inspect(req.body, {depth: 10})); - - // Only pull changed branches - var changes = implementation.getHeadChanges(req); - if (changes.length === 0) { - logger.trace('No changes in a relevant branch. Checking and updating tags'); - if (repo.repo_config.support_tags === true) { - repo.createNewTagsAsBranch(function(err, new_tags) { - if (err) return logger.error(err); - }); + if(implementation.isToken(req, config)) { + + // Only pull changed branches + var changes = implementation.getHeadChanges(req); + if (changes.length === 0) { + logger.trace('No changes in a relevant branch. Checking and updating tags'); + if (repo.repo_config.support_tags === true) { + repo.createNewTagsAsBranch(function(err, new_tags) { + if (err) return logger.error(err); + }); + } + return res.send(messageSend); } - return res.send('ok'); - } - for (var i=0; i