diff options
Diffstat (limited to 'git-tools/setup_github_network.php')
-rw-r--r-- | git-tools/setup_github_network.php | 31 |
1 files 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(); } -foreach ($remotes as $remote) +if (file_exists('.git')) { - if ($remote['username'] == $username) - { - // Skip blessed repository. - continue; - } + 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) +{ 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"); } } |