<commit_before>
FILE_NAME_FOR_INSERT = ARGV[0]
BEGIN_INSERT_LINE = "//begin #{File.basename(__FILE__)}"
END_INSERT_LINE = "//end #{File.basename(__FILE__)}"

if(!File.exists?(FILE_NAME_FOR_INSERT) || !File.writable?(FILE_NAME_FOR_INSERT))
    abort("Can't find or can't write to #{FILE_NAME_FOR_INSERT}")
end

newFileContent = ""
fileToModify = File.new(FILE_NAME_FOR_INSERT, "r")

#Include the old stuff up to BEGIN_INSERT_LINE of file
while true
    line = fileToModify.gets
    if line.nil?
        abort("hit EOF before finding \"#{BEGIN_INSERT_LINE}\"") 
    elsif line.chomp == BEGIN_INSERT_LINE
        break
    else
        newFileContent += line
    end
end

newFileContent += BEGIN_INSERT_LINE + "\n"

#Include the new stuff from STDIN
while line = STDIN.gets
    newFileContent += line
end

#EXCLUDE the old stuff up to END_INSERT_LINE of file
while true
    line = fileToModify.gets
    if line.nil?
        abort("hit EOF before finding \"#{END_INSERT_LINE}\"")
    elsif line.chomp == END_INSERT_LINE
        break
    end
end

newFileContent += END_INSERT_LINE + "\n"

#include the old stuff after END_INSERT_LINE of file
while line = fileToModify.gets
    newFileContent += line
end

#write new file contents over old
fileToModify.close
fileToModify = File.new(FILE_NAME_FOR_INSERT, "w")
fileToModify.write(newFileContent)
fileToModify.close

<commit_msg>Added ability to stop insert_method_hooking_tests.rb from running on build<commit_after>
FILE_NAME_FOR_INSERT = ARGV[0]
BEGIN_INSERT_LINE = "//begin #{File.basename(__FILE__)}"
END_INSERT_LINE = "//end #{File.basename(__FILE__)}"
DONT_INSERT_LINE = "//dont insert"

if(!File.exists?(FILE_NAME_FOR_INSERT) || !File.writable?(FILE_NAME_FOR_INSERT))
    abort("Can't find or can't write to #{FILE_NAME_FOR_INSERT}")
end

newFileContent = ""
fileToModify = File.new(FILE_NAME_FOR_INSERT, "r")

if(fileToModify.gets.chomp == DONT_INSERT_LINE)
    exit
else
    fileToModify.seek(0)
end

#Include the old stuff up to BEGIN_INSERT_LINE of file
while true
    line = fileToModify.gets
    if line.nil?
        abort("hit EOF before finding \"#{BEGIN_INSERT_LINE}\"") 
    elsif line.chomp == BEGIN_INSERT_LINE
        break
    else
        newFileContent += line
    end
end

newFileContent += BEGIN_INSERT_LINE + "\n"

#Include the new stuff from STDIN
while line = STDIN.gets
    newFileContent += line
end

#EXCLUDE the old stuff up to END_INSERT_LINE of file
while true
    line = fileToModify.gets
    if line.nil?
        abort("hit EOF before finding \"#{END_INSERT_LINE}\"")
    elsif line.chomp == END_INSERT_LINE
        break
    end
end

newFileContent += END_INSERT_LINE + "\n"

#include the old stuff after END_INSERT_LINE of file
while line = fileToModify.gets
    newFileContent += line
end

#write new file contents over old
fileToModify.close
fileToModify = File.new(FILE_NAME_FOR_INSERT, "w")
fileToModify.write(newFileContent)
fileToModify.close


{'fraction_non_alphanumeric': 0.09788540245566166, 'fraction_numerical': 0.0010231923601637107, 'mean_word_length': 4.118673647469459, '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': '3103285', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1011, 'n_words': 261}