Example #1
0
/**
 * @param $msg
 * @param bool $displaySuccess
 * @param bool $dieOnRemainingChanges
 * @return int
 */
function commit($msg, $displaySuccess = true, $dieOnRemainingChanges = true)
{
    $msg = escapeshellarg($msg);
    `svn ci -m {$msg}`;
    if ($dieOnRemainingChanges && has_uncommited_changes('.')) {
        error("Commit seems to have failed. Uncommited changes exist in the working folder.\n");
    }
    return (int) get_info('.')->entry->commit['revision'];
}
Example #2
0
if (!isset($_SERVER['argc']) || $_SERVER['argc'] != 3) {
    error("Missing argument. Expecting tagged version to build increment from and to.\n\nExamples:\n\t2.0 2.2\n\t2.1 2.2");
}
$fromVersion = $_SERVER['argv'][1];
$toVersion = $_SERVER['argv'][2];
$from = full("tags/{$fromVersion}");
$to = full("tags/{$toVersion}");
$fromRep = get_info($source);
$toRep = get_info($branch);
$local = get_info('.');
if (!isset($fromRep->entry)) {
    error("The origin tag does not exist.");
}
if (!isset($toRep->entry)) {
    error("The destination tag does not exist.");
}
if (!isset($local->entry)) {
    error("The current folder is not a local copy.");
}
if (has_uncommited_changes('.')) {
    error("Local copy contains uncommited changes.");
}
info("Converting local copy to origin.");
`svn switch {$from}`;
$tar = "tikiwiki-inc-{$fromVersion}-to-{$toVersion}.tar";
info("Converting to destination and packaging.");
`svn switch {$to} | awk '/^[UA] / {print \$2}' | grep -v devtools | xargs tar --exclude "*.svn*" -cf {$tar}`;
`gzip -5 {$tar}`;
info("Reverting to prior status.");
`svn switch {$local->entry->url}`;
echo "{$tar}.gz was created.\n";
Example #3
0
/**
 * @param $msg
 * @param bool $increment_step
 * @param bool $commit_msg
 * @return bool
 */
function important_step($msg, $increment_step = true, $commit_msg = false)
{
    global $options;
    static $step = 0;
    // Auto-Skip the step if this is a commit step and if there is nothing to commit
    if ($commit_msg && !has_uncommited_changes('.')) {
        return false;
    }
    // Increment step number if needed
    if ($increment_step) {
        $step++;
    }
    if ($commit_msg && $options['no-commit']) {
        print "Skipping actual commit ('{$commit_msg}') because no-commit = true\n";
        return;
    }
    $do_step = false;
    if ($options['force-yes']) {
        important("\n{$step}) {$msg}...");
        $do_step = true;
    } else {
        important("\n{$step}) {$msg}?");
        $prompt = '[Y/n/q/?] ';
        if (function_exists('readline')) {
            // readline function requires php readline extension...
            $c = readline($prompt);
        } else {
            echo $prompt;
            $c = rtrim(fgets(STDIN), "\n");
        }
        switch (strtolower($c)) {
            case 'y':
            case '':
                $do_step = true;
                break;
            case 'n':
                info(">> Skipping step {$step}.");
                $do_step = false;
                break;
            case 'q':
                die;
                break;
            default:
                if ($c != '?') {
                    info(color(">> Unknown answer '{$c}'.", 'red'));
                }
                info(">> You have to type 'y' (Yes), 'n' (No) or 'q' (Quit) and press Enter.");
                return important_step($msg, false);
        }
    }
    if ($commit_msg && $do_step && ($revision = commit($commit_msg))) {
        info(">> Commited revision {$revision}.");
    }
    return $do_step;
}