pharext\Task\GitClone::run PHP Method

run() public method

public run ( boolean $verbose = false ) : Tempdir
$verbose boolean
return pharext\Tempdir
    public function run($verbose = false)
    {
        if ($verbose !== false) {
            printf("Fetching %s ...\n", $this->source);
        }
        $local = new Tempdir("gitclone");
        $cmd = new ExecCmd("git", $verbose);
        if (strlen($this->branch)) {
            $cmd->run(["clone", "--depth", 1, "--branch", $this->branch, $this->source, $local]);
        } else {
            $cmd->run(["clone", $this->source, $local]);
        }
        return $local;
    }

Usage Example

Exemplo n.º 1
0
 function testGitClone()
 {
     $cmd = new Task\GitClone("https://git.php.net/repository/pecl/http/apfd.git");
     $dir = $cmd->run();
     $this->assertTrue(is_dir("{$dir}/.git"), "is_dir({$dir}/.git)");
     (new Task\Cleanup($dir))->run();
     $this->assertFalse(is_dir($dir), "is_dir({$dir})");
 }