<commit_before><script type="text/javascript">


function renameFilenameModal(filename) {
    $("#oldFilename").val(filename);
    $("#newFilename").val(filename);
    $("#filenameModal").modal('show');
}

function renameFilename() {
    $.post("{{ path('AceUtilitiesBundle_renamefile', {'id':project_id} ) }}", {oldFilename: $("#oldFilename").val(), newFilename: $("#newFilename").val()}, function (data) {
        $("#filenameModal").modal('hide');
        handleResponse(data);
    });
}

function handleResponse(response) {
    var response = JSON.parse(response);
    if (response["success"])
        location.reload();
    else {
        setOperationOutput(response["error"]);
        $(".modal").modal('hide');
    }
}

function setOperationProgress(newprogress) {
    $("#progress").show('fast');
    $("#progress_val").width(newprogress + '%');
    $("#operation_output").hide('fast');
    // $("#progress").show('fast');
    // if(newprogress < 10)
    // 	window.currentProgress = 0.5*newprogress;
    // else
    // 	window.currentProgress = 0;
    // $("#progress_val").width(window.currentProgress+'%');
    //
    // window.maxProgress = newprogress;
    // window.interval = setInterval(function()
    // {
    // 	$("#progress_val").width(window.currentProgress+'%');
    // 	if(window.currentProgress < window.maxProgress)
    // 		window.currentProgress++;
    // },10);
    // $("#operation_output").hide('fast');
}

function setOperationOutput(output) {
    $("#progress").hide('fast');
    $("#progress_val").width('0%');
    $("#operation_output").html(output).show('fast');
    //clear the interval here
}

function save() {
    loadCode();
    setOperationProgress(90);
    $.post("{{ path('AceUtilitiesBundle_savecode', {'id': fpath}) }}", {data: JSON.stringify(window.files), project_id: {{ project_id }} }, function (data) {
        $("#save").addClass("btn-success");
        $("#save_icon").addClass("icon-white");
        data = JSON.parse(data);
        setOperationOutput(data['message']);
        window.setTimeout(function () {
            $("#save").removeClass("btn-success");
            $("#save_icon").removeClass("icon-white");
        }, 500);
        //   alert("Data received: " +JSON.stringify(data, null, 4));
    });
}

function save_to_github(repo_name) {
    $("#repoName").val(repo_name);
    $("#commitModal").modal('show');
}

function delete_from_github(repo_name){

    var oauthProvider = 'github';
    var user_name = '';
    var token = '';
    // get the user's username :user
    OAuth.popup(oauthProvider, function(err, suc){
        if (suc) {
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/user?access_token=' + suc.access_token,
                dataType: 'json',
                async: false,
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    user_name = json.login;
                },
                error: function(req, status, er) {
                    alert("ERROR: "+ req.responseText);
                }
            });
            //$('#result').html("// Result success <br /><br />" + JSON.stringify(suc, undefined, 2));
        }
        else {
           // $('#result').html("// Result error <br /><br />" + err);
        }
    });

    // delete the user's repository
    OAuth.popup(oauthProvider, function(error, success){
        if (success) {
            $.ajax
            ({
                type: "DELETE",
                url: 'https://api.github.com/repos/' + user_name +'/' +repo_name+ '?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                success: function () {
                    alert("Repository '"+ repo_name + "' deleted on GitHub.com!");
                    $.post("{{ path('AceUtilitiesBundle_setprojectgiturl', {'id':project_id} ) }}", {data: ""}, function (data) {
                        $("#div_git_url").html("");
                        $("#div_delete_from_github").html("");
                        $("#div_git_url").css('display','none');

                    });

                    $.post("{{ path('AceUtilitiesBundle_setprojectgitcommitsha', {'id':project_id} ) }}", {data: ""}, function (data) {
                    });
                },
                error: function(request, status, error) {
                    alert("ERROR: "+ request.responseText);
                }
            });
        }
        else {
           // $('#result').html("// Result error <br /><br />" + error);
        }
    });
}

function pull_from_github(repo_name, git_commit_sha) {
    // the possible values for oauthProvider are 'github', 'facebook', .... etc. All in lowercase!
    var oauthProvider = 'github';
    var user_name = '';
    var token = '';


    OAuth.popup(oauthProvider, function (error, success) {
        if (success) {

            // GET  /user
            // Get the authenticated user
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/user?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                data: '',
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    user_name = json.login;
                    token = success.access_token;
                },
                error: function (request, status, error) {
                    alert("ERROR: " + request.responseText);
                    return;
                }
            });

            //GET /repos/:user/:repo/git/refs/heads/master
            //Store the SHA for the latest commit (SHA-LATEST-COMMIT)
            var old_commit_sha = '';
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/repos/' + user_name + '/' + repo_name + '/git/refs/heads/master?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                data: '',
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    old_commit_sha = json.object.sha;
                    if(old_commit_sha.trim().toLowerCase() == git_commit_sha ){
                        alert("Nothing to pull from the branch - master!")
                    }else{<commit_msg>Trying to get the contents from a commit<commit_after><script type="text/javascript">


function renameFilenameModal(filename) {
    $("#oldFilename").val(filename);
    $("#newFilename").val(filename);
    $("#filenameModal").modal('show');
}

function renameFilename() {
    $.post("{{ path('AceUtilitiesBundle_renamefile', {'id':project_id} ) }}", {oldFilename: $("#oldFilename").val(), newFilename: $("#newFilename").val()}, function (data) {
        $("#filenameModal").modal('hide');
        handleResponse(data);
    });
}

function handleResponse(response) {
    var response = JSON.parse(response);
    if (response["success"])
        location.reload();
    else {
        setOperationOutput(response["error"]);
        $(".modal").modal('hide');
    }
}

function setOperationProgress(newprogress) {
    $("#progress").show('fast');
    $("#progress_val").width(newprogress + '%');
    $("#operation_output").hide('fast');
    // $("#progress").show('fast');
    // if(newprogress < 10)
    // 	window.currentProgress = 0.5*newprogress;
    // else
    // 	window.currentProgress = 0;
    // $("#progress_val").width(window.currentProgress+'%');
    //
    // window.maxProgress = newprogress;
    // window.interval = setInterval(function()
    // {
    // 	$("#progress_val").width(window.currentProgress+'%');
    // 	if(window.currentProgress < window.maxProgress)
    // 		window.currentProgress++;
    // },10);
    // $("#operation_output").hide('fast');
}

function setOperationOutput(output) {
    $("#progress").hide('fast');
    $("#progress_val").width('0%');
    $("#operation_output").html(output).show('fast');
    //clear the interval here
}

function save() {
    loadCode();
    setOperationProgress(90);
    $.post("{{ path('AceUtilitiesBundle_savecode', {'id': fpath}) }}", {data: JSON.stringify(window.files), project_id: {{ project_id }} }, function (data) {
        $("#save").addClass("btn-success");
        $("#save_icon").addClass("icon-white");
        data = JSON.parse(data);
        setOperationOutput(data['message']);
        window.setTimeout(function () {
            $("#save").removeClass("btn-success");
            $("#save_icon").removeClass("icon-white");
        }, 500);
        //   alert("Data received: " +JSON.stringify(data, null, 4));
    });
}

function save_to_github(repo_name) {
    $("#repoName").val(repo_name);
    $("#commitModal").modal('show');
}

function delete_from_github(repo_name){

    var oauthProvider = 'github';
    var user_name = '';
    var token = '';
    // get the user's username :user
    OAuth.popup(oauthProvider, function(err, suc){
        if (suc) {
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/user?access_token=' + suc.access_token,
                dataType: 'json',
                async: false,
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    user_name = json.login;
                },
                error: function(req, status, er) {
                    alert("ERROR: "+ req.responseText);
                }
            });
            //$('#result').html("// Result success <br /><br />" + JSON.stringify(suc, undefined, 2));
        }
        else {
           // $('#result').html("// Result error <br /><br />" + err);
        }
    });

    // delete the user's repository
    OAuth.popup(oauthProvider, function(error, success){
        if (success) {
            $.ajax
            ({
                type: "DELETE",
                url: 'https://api.github.com/repos/' + user_name +'/' +repo_name+ '?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                success: function () {
                    alert("Repository '"+ repo_name + "' deleted on GitHub.com!");
                    $.post("{{ path('AceUtilitiesBundle_setprojectgiturl', {'id':project_id} ) }}", {data: ""}, function (data) {
                        $("#div_git_url").html("");
                        $("#div_delete_from_github").html("");
                        $("#div_git_url").css('display','none');

                    });

                    $.post("{{ path('AceUtilitiesBundle_setprojectgitcommitsha', {'id':project_id} ) }}", {data: ""}, function (data) {
                    });
                },
                error: function(request, status, error) {
                    alert("ERROR: "+ request.responseText);
                }
            });
        }
        else {
           // $('#result').html("// Result error <br /><br />" + error);
        }
    });
}

function pull_from_github(repo_name, git_commit_sha) {
    var oauthProvider = 'github';
    var user_name = '';
    var token = '';

    OAuth.popup(oauthProvider, function (error, success) {
        if (success) {

            // GET  /user
            // Get the authenticated user
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/user?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                data: '',
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    user_name = json.login;
                    token = success.access_token;
                },
                error: function (request, status, error) {
                    alert("ERROR: " + request.responseText);
                    return;
                }
            });

            //GET /repos/:user/:repo/git/refs/heads/master
            //Store the SHA for the latest commit (SHA-LATEST-COMMIT)
            var old_commit_sha = '';
            $.ajax
            ({
                type: "GET",
                url: 'https://api.github.com/repos/' + user_name + '/' + repo_name + '/git/refs/heads/master?access_token=' + success.access_token,
                dataType: 'json',
                async: false,
                data: '',
                success: function (data) {
                    var json = $.parseJSON(JSON.stringify(data, undefined, 2));
                    old_commit_sha = json.object.sha;
                    if(old_commit_sha.trim().toLowerCase() == git_commit_sha ){
                        alert("Nothing to pull from the branch - master!")
                    }else{
                        // GET /repos/:owner/:repo/contents/:path
                        // get contents of the _app.cpp file from the master branch
                        $.ajax
                        ({
                            type: "GET",
                            url: 'https://api.github.com/repos/' + user_name + '/' + repo_name + '/contents/' + repo_name + '_app.cpp?access_token=' + success.access_token +'&ref=' + old_commit_sha,
                            dataType: 'json',
                            async: false,
                            data: '',
                            success: function (data) {
                                var json_file = $.parseJSON(JSON.stringify(data, undefined, 2));
                                var file_contents = json_file.content;
                                token = success.sha;
                                // update the sha !!!
                                //update_git_sha({{ project_id }}, );
                            },
                            error: function (request, status, error) {
                                alert("ERROR: " + request.responseText);
                                return;
                            }
                        });

{'fraction_non_alphanumeric': 0.16520149096279627, 'fraction_numerical': 0.0026021520500738447, 'mean_word_length': 1.7090874452276623, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6027636', 'n_tokens_mistral': 3885, 'n_tokens_neox': 3760, 'n_words': 698}