<commit_before><?php
$c = array(
    'require' => array(
        "koala-framework/koala-framework" => "dev-master"
    )
);
if (is_file('vkwf_branch')) {
    exec("git rm vkwf_branch");
    echo "removed kwf_branch file, composer.json is used instead\n";
    $c['require']['vivid-planet/vkwf'] = 'dev-master';
    $c['repositories'] = array(
        array(
            'type' => 'composer',
            'url' => 'http://packages.vivid-planet.com/'
        )
    );
} else if (is_file('kwf_branch')) {
    unlink('kwf_branch');
    echo "removed kwf_branch file, composer.json is used instead\n";
}
if (!file_exists('composer.json')) {
    file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
    echo "created default composer.json\n";
    exec("git add composer.json");
    file_put_contents('composer.lock', '');
    exec("git add composer.lock");
}

function deleteCacheFolder($path)
{
    if (!file_exists($path)) return;
    system("git rm $path/.gitignore");
    clearstatcache();
    if (!file_exists($path)) return;

    $it = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($path),
        RecursiveIteratorIterator::CHILD_FIRST
    );
    foreach ($it as $file) {
        if (in_array($file->getBasename(), array('.', '..'))) {
            continue;
        } elseif ($file->isDir()) {
            rmdir($file->getPathname());
        } elseif ($file->isFile() || $file->isLink()) {
            unlink($file->getPathname());
        }
    }
    rmdir($path);
}

function glob_recursive($pattern, $flags = 0) {
    $files = glob($pattern, $flags);
    foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
        if (dirname($dir) == './kwf-lib' || $dir == './kwf-lib') continue;
        if (dirname($dir) == './vkwf-lib' || $dir == './vkwf-lib') continue;
        if (dirname($dir) == './library' || $dir == './library') continue;
        if (dirname($dir) == './vendor' || $dir == './vendor') continue;
        $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
    }
    return $files;
}

if (!file_exists('scss')) {
    mkdir('scss');
    mkdir('scss/config');
    file_put_contents('scss/config/.gitkeep', '');
    system('git add scss/config/.gitkeep');
}

if (!is_dir('cache/uglifyjs')) {
    mkdir('cache/uglifyjs');
    file_put_contents('cache/uglifyjs/.gitignore', "*\n!.gitignore\n");
    system("git add cache/uglifyjs/.gitignore");
    echo "folder \"cache/uglifyjs\" created\n";
}

deleteCacheFolder('cache/events');
deleteCacheFolder('cache/table');
deleteCacheFolder('cache/trl');

$c = file(".gitignore", FILE_IGNORE_NEW_LINES);
$c[] = '/build';
$c[] = '/vendor';
$c[] = 'bower.json';
$c[] = '.bowerrc';
$c = array_filter($c); //remove empty lines
$c = array_unique($c);
file_put_contents('.gitignore', implode("\n", $c)."\n");
echo ".gitignore updated to ignore build and vendor\n";


$c = file_get_contents('bootstrap.php');
$c = preg_replace("#require(_once)? 'kwf-lib/([^']*)';#", "require 'vendor/koala-framework/koala-framework/\\2';", $c);
$c = preg_replace("#require(_once)? 'vkwf-lib/([^']*)';#", "require 'vendor/vivid-planet/vkwf/\\2';", $c);
file_put_contents('bootstrap.php', $c);
echo "bootstrap.php updated to require kwf from vendor\n";

$libDirs = array('kwf-lib', 'vkwf-lib', 'library');
foreach ($libDirs as $libDir) {
    if (file_exists($libDir)) {
        if (is_link($libDir)) {
            unlink($libDir);
            echo "$libDir symlink removed, vendor is now used\n";
        } else {
            echo "$libDir is not used anymore, we switched to composer. Delete it manually.\n";
        }
    }
}

// ********* Ext -> Ext2
class MyRecursiveFilterIterator extends RecursiveFilterIterator {

    public static $FILTERS = array(
        'build', 'vendor', 'cache', '.git', '.svn', 'log', 'temp', 'uploads'
    );
<commit_msg>specify gitignore path with / so our sync doesn't use this isgnore in subfolders<commit_after><?php
$c = array(
    'require' => array(
        "koala-framework/koala-framework" => "dev-master"
    )
);
if (is_file('vkwf_branch')) {
    exec("git rm vkwf_branch");
    echo "removed kwf_branch file, composer.json is used instead\n";
    $c['require']['vivid-planet/vkwf'] = 'dev-master';
    $c['repositories'] = array(
        array(
            'type' => 'composer',
            'url' => 'http://packages.vivid-planet.com/'
        )
    );
} else if (is_file('kwf_branch')) {
    unlink('kwf_branch');
    echo "removed kwf_branch file, composer.json is used instead\n";
}
if (!file_exists('composer.json')) {
    file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
    echo "created default composer.json\n";
    exec("git add composer.json");
    file_put_contents('composer.lock', '');
    exec("git add composer.lock");
}

function deleteCacheFolder($path)
{
    if (!file_exists($path)) return;
    system("git rm $path/.gitignore");
    clearstatcache();
    if (!file_exists($path)) return;

    $it = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($path),
        RecursiveIteratorIterator::CHILD_FIRST
    );
    foreach ($it as $file) {
        if (in_array($file->getBasename(), array('.', '..'))) {
            continue;
        } elseif ($file->isDir()) {
            rmdir($file->getPathname());
        } elseif ($file->isFile() || $file->isLink()) {
            unlink($file->getPathname());
        }
    }
    rmdir($path);
}

function glob_recursive($pattern, $flags = 0) {
    $files = glob($pattern, $flags);
    foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
        if (dirname($dir) == './kwf-lib' || $dir == './kwf-lib') continue;
        if (dirname($dir) == './vkwf-lib' || $dir == './vkwf-lib') continue;
        if (dirname($dir) == './library' || $dir == './library') continue;
        if (dirname($dir) == './vendor' || $dir == './vendor') continue;
        $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
    }
    return $files;
}

if (!file_exists('scss')) {
    mkdir('scss');
    mkdir('scss/config');
    file_put_contents('scss/config/.gitkeep', '');
    system('git add scss/config/.gitkeep');
}

if (!is_dir('cache/uglifyjs')) {
    mkdir('cache/uglifyjs');
    file_put_contents('cache/uglifyjs/.gitignore', "*\n!.gitignore\n");
    system("git add cache/uglifyjs/.gitignore");
    echo "folder \"cache/uglifyjs\" created\n";
}

deleteCacheFolder('cache/events');
deleteCacheFolder('cache/table');
deleteCacheFolder('cache/trl');

$c = file(".gitignore", FILE_IGNORE_NEW_LINES);
$c[] = '/build';
$c[] = '/vendor';
$c[] = '/bower.json';
$c[] = '/.bowerrc';
$c = array_filter($c); //remove empty lines
$c = array_unique($c);
file_put_contents('.gitignore', implode("\n", $c)."\n");
echo ".gitignore updated to ignore build and vendor\n";


$c = file_get_contents('bootstrap.php');
$c = preg_replace("#require(_once)? 'kwf-lib/([^']*)';#", "require 'vendor/koala-framework/koala-framework/\\2';", $c);
$c = preg_replace("#require(_once)? 'vkwf-lib/([^']*)';#", "require 'vendor/vivid-planet/vkwf/\\2';", $c);
file_put_contents('bootstrap.php', $c);
echo "bootstrap.php updated to require kwf from vendor\n";

$libDirs = array('kwf-lib', 'vkwf-lib', 'library');
foreach ($libDirs as $libDir) {
    if (file_exists($libDir)) {
        if (is_link($libDir)) {
            unlink($libDir);
            echo "$libDir symlink removed, vendor is now used\n";
        } else {
            echo "$libDir is not used anymore, we switched to composer. Delete it manually.\n";
        }
    }
}

// ********* Ext -> Ext2
class MyRecursiveFilterIterator extends RecursiveFilterIterator {

    public static $FILTERS = array(
        'build', 'vendor', 'cache', '.git', '.svn', 'log', 'temp', 'uploads'
    );

{'fraction_non_alphanumeric': 0.2032631710051065, 'fraction_numerical': 0.00149458213974343, 'mean_word_length': 3.458634092171016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '3685181', 'n_tokens_mistral': 2781, 'n_tokens_neox': 2741, 'n_words': 546}