X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FTask%2FGitClone.php;h=55d759040416fb377aa63dba663f64273e3d0c55;hb=15854cb90bf0451eea42256bc61c95a9dadf8ba5;hp=709a34a3af32aa2ebe7215d031420ff3c093820d;hpb=861260c111bff72f60665393660b6f5375559510;p=pharext%2Fpharext diff --git a/src/pharext/Task/GitClone.php b/src/pharext/Task/GitClone.php index 709a34a..55d7590 100644 --- a/src/pharext/Task/GitClone.php +++ b/src/pharext/Task/GitClone.php @@ -15,12 +15,18 @@ class GitClone implements Task * @var string */ private $source; + + /** + * @var string + */ + private $branch; /** * @param string $source git repo location */ - public function __construct($source) { + public function __construct($source, $branch = null) { $this->source = $source; + $this->branch = $branch; } /** @@ -28,9 +34,16 @@ class GitClone implements Task * @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); - $cmd->run(["clone", $this->source, $local]); + if (strlen($this->branch)) { + $cmd->run(["clone", "--depth", 1, "--branch", $this->branch, $this->source, $local]); + } else { + $cmd->run(["clone", $this->source, $local]); + } return $local; } }