* @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;
}
/**
* @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;
}
}