From e1ae8c6a71e253f4311c45a6be5b2d93587d2755 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 25 Jan 2011 19:03:32 +0100 Subject: [PATCH] [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"); } }