<commit_before>#include <yuni/yuni.h>
#include <yuni/core/string.h>
#include <yuni/io/file.h>
#include <yuni/core/hash/checksum/md5.h>
#include <iostream>

using namespace Yuni;

namespace {

void writeFile(const AnyString& filename, const AnyString& content) {
	yuni::Hash::Checksum::MD5 md5;
	auto oldMD5 = md5.fromFile(filename);
	auto newMD5 = md5.fromRawData(content.c_str(), content.sizeInBytes());
	if (oldMD5 != newMD5) {
		auto lines = content.countChar('\n') + 1;
		std::cout << "updating " << filename << ": ";
		std::cout << "writing " << content.sizeInBytes() << " bytes, " << lines << " lines\n";
		IO::File::SetContent(filename, content);<commit_msg>tools: deny source modification from CI<commit_after>#include <yuni/yuni.h>
#include <yuni/core/string.h>
#include <yuni/io/file.h>
#include <yuni/core/hash/checksum/md5.h>
#include <yuni/core/system/environment.h>
#include <iostream>

using namespace Yuni;

namespace {

bool detectCI() {
	return yuni::System::Environment::ReadAsBool("CI")
		or yuni::System::Environment::ReadAsInt64("CI_JOB_ID");
}

void writeFile(const AnyString& filename, const AnyString& content) {
	yuni::Hash::Checksum::MD5 md5;
	auto oldMD5 = md5.fromFile(filename);
	auto newMD5 = md5.fromRawData(content.c_str(), content.sizeInBytes());
	if (oldMD5 != newMD5) {
		auto lines = content.countChar('\n') + 1;
		std::cout << "updating " << filename << ": ";
		std::cout << "writing " << content.sizeInBytes() << " bytes, " << lines << " lines\n";
		if (detectCI())
			throw "\n  NSL: source modifications not allowed from CI! Please commit the changes.\n";
		IO::File::SetContent(filename, content);
{'fraction_non_alphanumeric': 0.17754728492983526, 'fraction_numerical': 0.013422818791946308, 'mean_word_length': 5.3076923076923075, 'pattern_counts': {'":': 2, '<': 46, '<?xml version=': 0, '>': 14, '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': '6337488', 'n_tokens_mistral': 600, 'n_tokens_neox': 586, 'n_words': 123}