From 66be50ce71e5323378eb2759166acfd03ee886b8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 3 Apr 2012 19:49:57 +0200 Subject: [PATCH] Always set the push url after git updates --- src/Composer/Downloader/GitDownloader.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index e6949ea7a..5bd05a46d 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -34,13 +34,7 @@ class GitDownloader extends VcsDownloader }; $this->runCommand($commandCallable, $package->getSourceUrl(), $path); - - // set push url for github projects - if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) { - $pushUrl = 'git@github.com:'.$match[1].'/'.$match[2].'.git'; - $cmd = sprintf('cd %s && git remote set-url --push origin %s', escapeshellarg($path), escapeshellarg($pushUrl)); - $this->process->execute($cmd, $ignoredOutput); - } + $this->setPushUrl($package, $path); } /** @@ -58,6 +52,7 @@ class GitDownloader extends VcsDownloader }; $this->runCommand($commandCallable, $target->getSourceUrl()); + $this->setPushUrl($target, $path); } /** @@ -106,4 +101,14 @@ class GitDownloader extends VcsDownloader throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); } } + + protected function setPushUrl(PackageInterface $package, $path) + { + // set push url for github projects + if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) { + $pushUrl = 'git@github.com:'.$match[1].'/'.$match[2].'.git'; + $cmd = sprintf('git remote set-url --push origin %s', escapeshellarg($pushUrl)); + $this->process->execute($cmd, $ignoredOutput, $path); + } + } }