Example #1
0
function work($scope, $username, $repository, $developer)
{
    // Get some basic data
    $forks = get_forks($username, $repository);
    $collaborators = get_collaborators($username, $repository);
    if ($forks === false || $collaborators === false) {
        echo "Error: failed to retrieve forks or collaborators\n";
        return 1;
    }
    switch ($scope) {
        case 'collaborators':
            $remotes = array_intersect_key($forks, $collaborators);
            break;
        case 'organisation':
            $remotes = array_intersect_key($forks, get_organisation_members($username));
            break;
        case 'contributors':
            $remotes = array_intersect_key($forks, get_contributors($username, $repository));
            break;
        case 'forks':
            $remotes = $forks;
            break;
        default:
            show_usage();
    }
    if (file_exists('.git')) {
        add_remote($username, $repository, isset($collaborators[$developer]));
    } else {
        clone_repository($username, $repository, isset($collaborators[$developer]));
    }
    // Add private security repository for developers
    if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer])) {
        run("git remote add {$username}-security " . get_repository_url($username, "{$repository}-security", true));
    }
    // Skip blessed repository.
    unset($remotes[$username]);
    foreach ($remotes as $remote) {
        add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
    }
    run('git remote update');
}
Example #2
0
function work($pull_id, $remote)
{
    // Get some basic data
    $pull = get_pull('phpbb', 'phpbb3', $pull_id);
    if (!$pull_id) {
        show_usage();
    }
    if ($pull['state'] != 'open') {
        throw new RuntimeException(sprintf("Error: pull request is closed\n", $target_branch), 5);
    }
    $pull_user = $pull['head'][0];
    $pull_branch = $pull['head'][1];
    $target_branch = $pull['base'][1];
    switch ($target_branch) {
        case 'develop-olympus':
            run("git checkout develop-olympus");
            run("git pull {$remote} develop-olympus");
            add_remote($pull_user, 'phpbb3');
            run("git fetch {$pull_user}");
            run("git merge --no-ff {$pull_user}/{$pull_branch}");
            run("phpBB/vendor/bin/phpunit");
            run("git checkout develop");
            run("git pull {$remote} develop");
            run("git merge --no-ff develop-olympus");
            run("phpBB/vendor/bin/phpunit");
            break;
        case 'develop':
            run("git checkout develop");
            run("git pull {$remote} develop");
            add_remote($pull_user, 'phpbb3');
            run("git fetch {$pull_user}");
            run("git merge --no-ff {$pull_user}/{$pull_branch}");
            run("phpBB/vendor/bin/phpunit");
            break;
        default:
            throw new RuntimeException(sprintf("Error: pull request target branch '%s' is not a main branch\n", $target_branch), 5);
            break;
    }
}
Example #3
0
function add_remote()
{
    $arr = array("192.168.1.2", "11.1.2.4", "119.1.2.0/8");
    $REMOTE_XML = "fileName.xml";
    $remote = array();
    if (!($doc = simplexml_load_file($REMOTE_XML))) {
        echo __FUNCTION__ . ":打开文件" . $REMOTE_XML . "失败";
        exit;
    }
    $xml = $doc->UI->WEBUI->Allows;
    foreach ($arr as $remoteip) {
        $xml->addChild('Allow', $remoteip);
    }
    print_r($doc);
    $dom = new DOMDocument('1.0');
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    $dom->loadXML($doc->asXML());
    $dom->save('add.xml');
}
?>





<?php 
php > get_remote();
delete_remote();
add_remote();