From be3a0b269a7ddff2e5f0f2ae364cf2e50c780980 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 15 Jan 2011 02:06:23 +0100 Subject: [PATCH 1/7] [ticket/9805] Script for easily cloning a whole github network. PHPBB3-9805 --- git-tools/setup_github_network.php | 179 +++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 git-tools/setup_github_network.php diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php new file mode 100644 index 0000000000..bc8e70cfbd --- /dev/null +++ b/git-tools/setup_github_network.php @@ -0,0 +1,179 @@ +contributors as $contributor) + { + $usernames[$contributor->login] = $contributor->login; + } + + return $usernames; +} + +function get_organisation_members($username) +{ + $request = api_request("organizations/$username/public_members"); + + $usernames = array(); + foreach ($request->users as $member) + { + $usernames[$member->login] = $member->login; + } + + return $usernames; +} + +function get_collaborators($username, $repository) +{ + $request = api_request("repos/show/$username/$repository/collaborators"); + + $usernames = array(); + foreach ($request->collaborators as $collaborator) + { + $usernames[$collaborator] = $collaborator; + } + + return $usernames; +} + +function get_network($username, $repository) +{ + $request = api_request("repos/show/$username/$repository/network"); + + $usernames = array(); + foreach ($request->network as $network) + { + $usernames[$network->owner] = array( + 'username' => $network->owner, + 'repository' => $network->name, + ); + } + + return $usernames; +} + +function show_usage($argv) +{ + printf( + "usage: php %s collaborators|organisation|contributors|network [your_github_username]\n", + basename($argv[0]) + ); + exit(1); +} + +function get_arg($argv, $index, $default) +{ + return isset($argv[$index]) ? $argv[$index] : $default; +} + +function run($cmd) +{ + passthru(escapeshellcmd($cmd)); +} From 57bd0c74e50e2171653d45d9723f2417411c71f4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 16 Jan 2011 17:02:19 +0100 Subject: [PATCH 2/7] [ticket/9805] Use getopt(), add a few options, extend show_usage(). PHPBB3-9805 --- git-tools/setup_github_network.php | 52 +++++++++++++++++++----------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index bc8e70cfbd..66d7db87da 100644 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -9,7 +9,7 @@ if ($argc < 2) { - show_usage($argv); + show_usage(); } if (file_exists('.git')) @@ -18,13 +18,38 @@ if (file_exists('.git')) exit(1); } -// Handle arguments -$scope = get_arg($argv, 1, ''); -$developer = get_arg($argv, 2, ''); +function show_usage() +{ + $filename = basename(__FILE__); -// Github setup -$username = 'phpbb'; -$repository = 'phpbb3'; + echo "$filename adds repositories of a github network as remotes to a local git repository.\n"; + echo "\n"; + + echo "Usage: php $filename -s collaborators|organisation|contributors|network [OPTIONS]\n"; + echo "\n"; + + echo "Scopes:\n"; + echo " collaborators Repositories of people who have push access to the specified repository\n"; + echo " contributors Repositories of people who have contributed to the specified repository\n"; + echo " organisation Repositories of members of the organisation at github\n"; + echo " network All repositories of the whole github network\n"; + echo "\n"; + + echo "Options:\n"; + echo " -s scope See description above (mandatory)\n"; + echo " -u github_username Overwrites the github username (optional)\n"; + echo " -r repository_name Overwrites the repository name (optional)\n"; + echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n"; + + exit(1); +} + +// Handle arguments +$opts = getopt('s:u:r:m:'); +$scope = get_arg($opts, 's', ''); +$username = get_arg($opts, 'u', 'phpbb'); +$repository = get_arg($opts, 'r', 'phpbb3'); +$developer = get_arg($opts, 'm', ''); // Get some basic data $network = get_network($username, $repository); @@ -159,18 +184,9 @@ function get_network($username, $repository) return $usernames; } -function show_usage($argv) +function get_arg($array, $index, $default) { - printf( - "usage: php %s collaborators|organisation|contributors|network [your_github_username]\n", - basename($argv[0]) - ); - exit(1); -} - -function get_arg($argv, $index, $default) -{ - return isset($argv[$index]) ? $argv[$index] : $default; + return isset($array[$index]) ? $array[$index] : $default; } function run($cmd) From 8eee36dc0f6111c3a4a6a50d0e33833f19430a0e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 25 Jan 2011 18:41:59 +0100 Subject: [PATCH 3/7] [ticket/9805] Add dry-run option. PHPBB3-9805 --- git-tools/setup_github_network.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index 66d7db87da..04187aaa4a 100644 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -40,16 +40,19 @@ function show_usage() echo " -u github_username Overwrites the github username (optional)\n"; echo " -r repository_name Overwrites the repository name (optional)\n"; echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n"; + echo " -d Outputs the commands instead of running them (optional)\n"; exit(1); } // Handle arguments -$opts = getopt('s:u:r:m:'); +$opts = getopt('s:u:r:m:d'); $scope = get_arg($opts, 's', ''); $username = get_arg($opts, 'u', 'phpbb'); $repository = get_arg($opts, 'r', 'phpbb3'); $developer = get_arg($opts, 'm', ''); +$dry_run = !get_arg($opts, 'd', true); +run(null, $dry_run); // Get some basic data $network = get_network($username, $repository); @@ -189,7 +192,20 @@ function get_arg($array, $index, $default) return isset($array[$index]) ? $array[$index] : $default; } -function run($cmd) +function run($cmd, $dry = false) { - passthru(escapeshellcmd($cmd)); + static $dry_run; + + if (is_null($cmd)) + { + $dry_run = $dry; + } + else if (!empty($dry_run)) + { + echo "$cmd\n"; + } + else + { + passthru(escapeshellcmd($cmd)); + } } From e1ae8c6a71e253f4311c45a6be5b2d93587d2755 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 25 Jan 2011 19:03:32 +0100 Subject: [PATCH 4/7] [ticket/9805] Better support for already existing repositories. PHPBB3-9805 --- git-tools/setup_github_network.php | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index 04187aaa4a..f34787c4c4 100644 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -12,12 +12,6 @@ if ($argc < 2) show_usage(); } -if (file_exists('.git')) -{ - echo "[error] git repository already exists\n"; - exit(1); -} - function show_usage() { $filename = basename(__FILE__); @@ -58,9 +52,6 @@ run(null, $dry_run); $network = get_network($username, $repository); $collaborators = get_collaborators($username, $repository); -// Clone the blessed repository -clone_repository($username, $repository, isset($collaborators[$developer])); - switch ($scope) { case 'collaborators': @@ -83,14 +74,20 @@ switch ($scope) 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]); + foreach ($remotes as $remote) { - if ($remote['username'] == $username) - { - // Skip blessed repository. - continue; - } - add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer); } @@ -99,12 +96,12 @@ run('git remote update'); function clone_repository($username, $repository, $pushable = false) { $url = get_repository_url($username, $repository, false); - run("git clone $url ./"); + run("git clone $url ./ --origin $username"); if ($pushable) { $ssh_url = get_repository_url($username, $repository, true); - run("git remote set-url --push origin $ssh_url"); + run("git remote set-url --push $username $ssh_url"); } } From 67fe441f7e94aa9f502f3f8d3ff7ad15bb2ae008 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 25 Jan 2011 19:07:29 +0100 Subject: [PATCH 5/7] [ticket/9805] Move check lower down. PHPBB3-9805 --- git-tools/setup_github_network.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index f34787c4c4..911d336c2d 100644 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -7,11 +7,6 @@ * */ -if ($argc < 2) -{ - show_usage(); -} - function show_usage() { $filename = basename(__FILE__); @@ -40,7 +35,13 @@ function show_usage() } // Handle arguments -$opts = getopt('s:u:r:m:d'); +$opts = getopt('s:u:r:m:d'); + +if (empty($opts)) +{ + show_usage(); +} + $scope = get_arg($opts, 's', ''); $username = get_arg($opts, 'u', 'phpbb'); $repository = get_arg($opts, 'r', 'phpbb3'); From 50bdb5da89cdbca0d4331a7f4f721f8be712d0ca Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 26 Jan 2011 03:18:31 +0100 Subject: [PATCH 6/7] [ticket/9805] Setup security repository for developers. PHPBB3-9805 --- git-tools/setup_github_network.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index 911d336c2d..08e99e2f32 100644 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -84,6 +84,12 @@ 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]); From 0e861ac3ab0513ec1c00354bfc8fc8492aa6573c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 9 Feb 2011 02:14:46 -0500 Subject: [PATCH 7/7] [ticket/10029] Use $_SERVER['SERVER_PROTOCOL'] for determining HTTP version. PHPBB3-10029 --- phpBB/includes/functions.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a8cc5d6b3..398a02380b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2631,8 +2631,14 @@ function send_status_line($code, $message) } else { - if (isset($_SERVER['HTTP_VERSION'])) + if (!empty($_SERVER['SERVER_PROTOCOL'])) { + $version = $_SERVER['SERVER_PROTOCOL']; + } + else if (!empty($_SERVER['HTTP_VERSION'])) + { + // I cannot remember where I got this from. + // This code path may never be reachable in reality. $version = $_SERVER['HTTP_VERSION']; } else