<commit_before>var url = require('url');
var config = require ('./config.js');
var configData = config.data;
var http = require('http');
var https = require('https');
var qs = require ('querystring');
var secure_post = false;
var pull_field = configData.pullField || "ref";


// start up our pull server
function startServer (instance_data, checkAndUpdateEnvironment, cb){
    // create a server to listen for pull requests
    function handleRequests (req, res){
        function parseURL (req){
            var url_in = url.parse (req.url, true);
            req.query = url_in.query;
            req.href = url_in.href;
        }
        function bodyParser (req, res, func){
            if (req.method == 'POST') {
                var body = '';
                req.on('data', function (data) {
                    body += data;
                    if (body.length > 524488) { // limit the most data someone can send to 1/2 a meg
                        request.connection.destroy();
                    }
                });
                req.on('end', function () {
                    try{req.body = JSON.parse (body);}
                    catch (e){req.body = qs.parse (body);}
                    if (func){func (req, res);}
                });
            }
        }
        if (req.url.search ("/pull") !== -1){ // handle a command to pull
            var valid_request = true;
            parseURL (req);
            if (configData.pullSecret){
                valid_request = (req.query.secret == configData.pullSecret) ? true : false;
            }
            if (valid_request){
                bodyParser (req, res, function (){
                    var listensTo = (instance_data && instance_data.listensTo) ? instance_data.listensTo : "";
                    req.body[pull_field] = req.body[pull_field] || "";
                    if (req.body[pull_field].search (listensTo) !== -1){
                        if (req.body.args){
                            var args;
                            try {args = JSON.parse (req.body.args);}
                            catch (e){}
                            args = args || req.body.args;
                            if (args){ // only save these out if we have new ones
                                console.log ("\tApplying pullArgs:%j", args);
                                for (var k in args){
                                    configData.pullArgs[k] = args[k];
                                }
                                config.update ();
                            }
                            else{
                                console.log ("\tNo pullArgs passed in");
                            }
                        }

                        var _master = req.query.master;
                        checkAndUpdateEnvironment (function (){
                            res.writeHead(200, {'Content-Type': 'text/plain'});
                            res.end("Pull Accepted");
                            var date = new Date ();<commit_msg>Fixed an issue with the pull args getting cleared out<commit_after>var url = require('url');
var config = require ('./config.js');
var configData = config.data;
var http = require('http');
var https = require('https');
var qs = require ('querystring');
var secure_post = false;
var pull_field = configData.pullField || "ref";


// start up our pull server
function startServer (instance_data, checkAndUpdateEnvironment, cb){
    // create a server to listen for pull requests
    function handleRequests (req, res){
        function parseURL (req){
            var url_in = url.parse (req.url, true);
            req.query = url_in.query;
            req.href = url_in.href;
        }
        function bodyParser (req, res, func){
            if (req.method == 'POST') {
                var body = '';
                req.on('data', function (data) {
                    body += data;
                    if (body.length > 524488) { // limit the most data someone can send to 1/2 a meg
                        request.connection.destroy();
                    }
                });
                req.on('end', function () {
                    try{req.body = JSON.parse (body);}
                    catch (e){req.body = qs.parse (body);}
                    if (func){func (req, res);}
                });
            }
        }
        if (req.url.search ("/pull") !== -1){ // handle a command to pull
            var valid_request = true;
            parseURL (req);
            if (configData.pullSecret){
                valid_request = (req.query.secret == configData.pullSecret) ? true : false;
            }
            if (valid_request){
                bodyParser (req, res, function (){
                    var listensTo = (instance_data && instance_data.listensTo) ? instance_data.listensTo : "";
                    req.body[pull_field] = req.body[pull_field] || "";
                    if (req.body[pull_field].search (listensTo) !== -1){
                        if (req.body.args){
                            var args;
                            try {args = JSON.parse (req.body.args);}
                            catch (e){}
                            args = args || req.body.args;
                            if (args){ // only save these out if we have new ones
                                console.log ("\tApplying pullArgs:%j", args);
                                configData.pullArgs = configData.pullArgs || {};
                                for (var k in args){
                                    configData.pullArgs[k] = args[k];
                                }
                                config.update ();
                            }
                            else{
                                console.log ("\tNo pullArgs passed in");
                            }
                        }

                        var _master = req.query.master;
                        checkAndUpdateEnvironment (function (){
                            res.writeHead(200, {'Content-Type': 'text/plain'});
                            res.end("Pull Accepted");
                            var date = new Date ();
{'fraction_non_alphanumeric': 0.11289018275917839, 'fraction_numerical': 0.0042050784408863015, 'mean_word_length': 1.1479680444598819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1612069', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1483, 'n_words': 407}