Platformsh\Cli\Helper\GitHelper::cloneRepo PHP Method

cloneRepo() public method

A ProcessFailedException will be thrown if the command fails.
public cloneRepo ( string $url, string $destination = null, array $args = [], boolean $mustRun = false ) : boolean
$url string The Git repository URL.
$destination string A directory name to clone into.
$args array Extra arguments for the Git command.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean
    public function cloneRepo($url, $destination = null, array $args = [], $mustRun = false)
    {
        $args = array_merge(['clone', $url], $args);
        if ($destination) {
            $args[] = $destination;
        }
        return (bool) $this->execute($args, false, $mustRun, false);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Clone the app to the build directory via Git.
  *
  * @param string $buildDir
  */
 private function cloneToBuildDir($buildDir)
 {
     $gitRoot = $this->gitHelper->getRoot($this->appRoot, true);
     $ref = $this->gitHelper->execute(['rev-parse', 'HEAD'], $gitRoot, true);
     $cloneArgs = ['--recursive', '--shared'];
     $tmpRepo = $buildDir . '-repo';
     if (file_exists($tmpRepo)) {
         $this->fsHelper->remove($tmpRepo, true);
     }
     $this->gitHelper->cloneRepo($gitRoot, $tmpRepo, $cloneArgs, true);
     $this->gitHelper->checkOut($ref, $tmpRepo, true, true);
     $this->fsHelper->remove($tmpRepo . '/.git');
     $appDir = $tmpRepo . '/' . substr($this->appRoot, strlen($gitRoot));
     if (!rename($appDir, $buildDir)) {
         throw new \RuntimeException(sprintf('Failed to move app from %s to %s', $appDir, $buildDir));
     }
     $this->fsHelper->remove($tmpRepo);
 }
All Usage Examples Of Platformsh\Cli\Helper\GitHelper::cloneRepo