Пример #1
0
    apply_patch(ALLOC_MOD_DIR . "patches/patch-00053-alla.php");
}
// Apply all patches
if ($_REQUEST["apply_patches"]) {
    foreach ($abc123_files as $abc123_file) {
        $abc123_f = ALLOC_MOD_DIR . "patches/" . $abc123_file;
        if (!in_array($abc123_file, $abc123_applied_patches)) {
            apply_patch($abc123_f);
        }
    }
    // Apply a single patch
} else {
    if ($_REQUEST["apply_patch"] && $_REQUEST["patch_file"]) {
        $abc123_f = ALLOC_MOD_DIR . "patches/" . $_REQUEST["patch_file"];
        if (!in_array($abc123_file, $abc123_applied_patches)) {
            apply_patch($abc123_f);
        }
    } else {
        if ($_REQUEST["remove_patch"] && $_REQUEST["patch_file"]) {
            $abc123_f = ALLOC_MOD_DIR . "patches/" . $_REQUEST["patch_file"];
            $q = prepare("INSERT INTO patchLog (patchName, patchDesc, patchDate) \n                VALUES ('%s','%s','%s')", $_REQUEST["patch_file"], "Patch not applied.", date("Y-m-d H:i:s"));
            $db = new db_alloc();
            $db->query($q);
        }
    }
}
$abc123_applied_patches = get_applied_patches();
foreach ($abc123_files as $abc123_file) {
    if (!in_array($abc123_file, $abc123_applied_patches)) {
        $abc123_incomplete = true;
    }
        rmdir($tmp_patch);
        return true;
    } else {
        echo "\nFailed to update, see the patches here for the full diff:\n{$tmp_patch}\n";
        return false;
    }
}
/**
 * Replaces '"$package_name": "$old"' with '"$package_name": "$new"' in $composer_file
 */
function composer_replace_version($composer_file, $package_name, $old, $new)
{
    $composer = file_get_contents($composer_file);
    $composer = str_replace('"' . $package_name . '": "' . $old . '"', '"' . $package_name . '": "' . $new . '"', $composer);
    file_put_contents($composer_file, $composer);
}
$composer = load_composer($composer_file, $package_name);
$version_local = $composer['replace'][$package_name];
update_remote($remote_name, $remote);
$remote_tags = current_remote_tags($remote_name);
$version_remote = array_keys($remote_tags);
$version_remote = $version_remote[count($version_remote) - 1];
if ($version_remote != $version_local) {
    if (apply_patch($remote_tags[$version_local], $remote_tags[$version_remote])) {
        composer_replace_version($composer_file, $package_name, $version_local, $version_remote);
        $message = "Updated remote {$remote_name} from {$version_local} to {$version_remote}";
        exec("git add '{$composer_file}'");
        exec("git commit -m '{$message}'");
        echo "\n{$message}\n";
    }
}