aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-02-15 05:13:48 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-15 05:20:30 -0500
commited53cef0aaa2a23d4688c2429cc7961ad79ca496 (patch)
tree8fad7e0de02f42a33ee9309517f58b5980c00c62 /git-tools/setup_github_network.php
parent[ticket/10044] Added -h to setup_github_network.php. (diff)
downloadphpbb-ed53cef0aaa2a23d4688c2429cc7961ad79ca496.tar.gz
phpbb-ed53cef0aaa2a23d4688c2429cc7961ad79ca496.tar.bz2
phpbb-ed53cef0aaa2a23d4688c2429cc7961ad79ca496.zip
[ticket/10044] Stop when failed to retrieve network/collaborators.
PHPBB3-10044
Diffstat (limited to 'git-tools/setup_github_network.php')
-rwxr-xr-xgit-tools/setup_github_network.php90
1 files changed, 50 insertions, 40 deletions
diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php
index 9ada9e437a..a3606575b2 100755
--- a/git-tools/setup_github_network.php
+++ b/git-tools/setup_github_network.php
@@ -50,57 +50,67 @@ $repository = get_arg($opts, 'r', 'phpbb3');
$developer = get_arg($opts, 'm', '');
$dry_run = !get_arg($opts, 'd', true);
run(null, $dry_run);
+exit(work($scope, $username, $repository, $developer));
-// Get some basic data
-$network = get_network($username, $repository);
-$collaborators = get_collaborators($username, $repository);
-
-switch ($scope)
+function work($scope, $username, $repository, $developer)
{
- case 'collaborators':
- $remotes = array_intersect_key($network, $collaborators);
- break;
+ // Get some basic data
+ $network = get_network($username, $repository);
+ $collaborators = get_collaborators($username, $repository);
- case 'organisation':
- $remotes = array_intersect_key($network, get_organisation_members($username));
- break;
+ if ($network === false || $collaborators === false)
+ {
+ echo "Error: failed to retrieve network or collaborators\n";
+ return 1;
+ }
- case 'contributors':
- $remotes = array_intersect_key($network, get_contributors($username, $repository));
- break;
+ switch ($scope)
+ {
+ case 'collaborators':
+ $remotes = array_intersect_key($network, $collaborators);
+ break;
- case 'network':
- $remotes = $network;
- break;
+ case 'organisation':
+ $remotes = array_intersect_key($network, get_organisation_members($username));
+ break;
- default:
- show_usage();
-}
+ case 'contributors':
+ $remotes = array_intersect_key($network, get_contributors($username, $repository));
+ break;
-if (file_exists('.git'))
-{
- add_remote($username, $repository, isset($collaborators[$developer]));
-}
-else
-{
- clone_repository($username, $repository, isset($collaborators[$developer]));
-}
+ case 'network':
+ $remotes = $network;
+ break;
-// 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));
-}
+ default:
+ show_usage();
+ }
+
+ if (file_exists('.git'))
+ {
+ add_remote($username, $repository, isset($collaborators[$developer]));
+ }
+ else
+ {
+ clone_repository($username, $repository, isset($collaborators[$developer]));
+ }
-// Skip blessed repository.
-unset($remotes[$username]);
+ // 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));
+ }
-foreach ($remotes as $remote)
-{
- add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
-}
+ // Skip blessed repository.
+ unset($remotes[$username]);
+
+ foreach ($remotes as $remote)
+ {
+ add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
+ }
-run('git remote update');
+ run('git remote update');
+}
function clone_repository($username, $repository, $pushable = false)
{