Example #1
0
foreach (new PregMatchIterator('~^(.*)/task-([0-9]+)(-.+)?$~', $list) as $matches) {
    $issueId = $matches[2];
    if (isset($opts->before) && $issueId >= $opts->before) {
        continue;
    }
    $branchFullName = $matches[0];
    echo $issueId . ': ' . $branchFullName . ' ';
    $branch = new Branch($gitWorkingCopyDir, $branchFullName);
    $issue = new Issue();
    $issue->find($issueId);
    if ($issue->count()) {
        echo '[' . $issue->status['name'] . '] ';
        if (in_array($issue->status['id'], Naf::config('redmine.closed_issue_status_ids'))) {
            if (!$opts->force) {
                echo 'Delete ' . ($branch->isRemote() ? 'remote' : 'local') . ' branch? (y/N) ';
                $confirmed = $charInput->confirm();
            }
            if ($confirmed) {
                try {
                    $branch->delete();
                    echo ' Deleted';
                } catch (ShellCmd\Fault $e) {
                    echo $e->getMessage();
                }
            }
        }
    } else {
        echo 'Issue not found';
    }
    echo "\n";
}