<commit_before>var app = require('orangebox').app(1);
var exec = require('child_process').exec;
var path = require('path').resolve();
var extend = require('util')._extend;
var log = require('loglevel');

module.exports.init = function(opt) {

  var config = {
    token: '',
    port: 4400,
    branches: '*',
    events: 'push',
    onEvent: null,
    command: 'cd ' + path + '; git pull origin master; if git diff --name-status HEAD HEAD~1 | grep -e package.json -e shrinkwrap.js; then npm update; fi',
    exit: false
    logLevel: 'warn'
  };

  extend(config, opt);

  log.setDefaultLevel(config.logLevel || 'warn')
  app.all('/', function(req, res) {

    try {
      log.info('Request received!');
      log.debug(req);
      var json = JSON.parse(Object.keys(req.body)[0]);
    } catch (e) {
      console.error('gitlab-webhooker: Post data are not GitLab JSON');
      log.warn('gitlab-webhooker: Post data are not GitLab JSON');
      log.debug(e);
      var json = {};
    }

    var requestToken = req.header('x-gitlab-token') || req.query.token || false<commit_msg>return directly when JSON can't be evaluated<commit_after>var app = require('orangebox').app(1);
var exec = require('child_process').exec;
var path = require('path').resolve();
var extend = require('util')._extend;
var log = require('loglevel');

module.exports.init = function(opt) {

  var config = {
    token: '',
    port: 4400,
    branches: '*',
    events: 'push',
    onEvent: null,
    command: 'cd ' + path + '; git pull origin master; if git diff --name-status HEAD HEAD~1 | grep -e package.json -e shrinkwrap.js; then npm update; fi',
    exit: false
    logLevel: 'warn'
  };

  extend(config, opt);

  log.setDefaultLevel(config.logLevel || 'warn')
  app.all('/', function(req, res) {

    try {
      log.info('Request received!');
      log.debug(req);
      var json = JSON.parse(Object.keys(req.body)[0]);
    } catch (e) {
      log.warn('gitlab-webhooker: Post data are not GitLab JSON');
      log.debug(e);
      var json = {};
      res.status(400).send({status: 'Post data are not GitLab JSON'});
      return false;
    }

    var requestToken = req.header('x-gitlab-token') || req.query.token || false
{'fraction_non_alphanumeric': 0.16681776971894832, 'fraction_numerical': 0.0077062556663644605, 'mean_word_length': 3.172022684310019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1473422', 'n_tokens_mistral': 749, 'n_tokens_neox': 713, 'n_words': 189}