function work($scope, $username, $repository, $developer)
{
	// Get some basic data
	$network		= get_network($username, $repository);
	$collaborators	= get_collaborators($username, $repository);

	if ($network === false || $collaborators === false)
	{
		echo "Error: failed to retrieve network or collaborators\n";
		return 1;
	}

	switch ($scope)
	{
		case 'collaborators':
			$remotes = array_intersect_key($network, $collaborators);
		break;

		case 'organisation':
			$remotes = array_intersect_key($network, get_organisation_members($username));
		break;

		case 'contributors':
			$remotes = array_intersect_key($network, get_contributors($username, $repository));
		break;

		case 'network':
			$remotes = $network;
		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("phpunit");

			run("git checkout develop");
			run("git pull $remote develop");
			run("git merge --no-ff develop-olympus");
			run("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("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
    dumpkey($key);
    return $key;
}
function str2hex($keystr)
{
    $key = array();
    foreach (str_split($keystr, 2) as $hex) {
        $key[] = hexdec($hex);
    }
    return $key;
}
function show_usage()
{
    global $argv;
    echo "{$argv['0']} [-r|-f] 012345679ABCDEF\n";
}
if ($argc == 3) {
    $key = str2hex($argv[2]);
    switch ($argv[1]) {
        case '-f':
            generate($key);
            break;
        case '-r':
            generate_rev($key);
            break;
        default:
            show_usage();
    }
} else {
    show_usage();
}