CliArgs::REQUIRED|CliArgs::SINGLE|CliArgs::REQARG],
["g", "git", "Use `git ls-tree` to determine file list",
CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG],
+ ["b", "branch", "Checkout this tag/branch",
+ CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::REQARG],
["p", "pecl", "Use PECL package.xml to determine file list, name and release",
CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG],
["d", "dest", "Destination directory",
*/
private function download($source) {
if ($this->args->git) {
- $task = new Task\GitClone($source);
+ $task = new Task\GitClone($source, $this->args->branch);
} else {
/* print newline only once */
$done = false;
* @return string local source directory
*/
private function localize($source) {
- if (!stream_is_local($source)) {
+ if (!stream_is_local($source) || ($this->args->git && isset($this->args->branch))) {
$source = $this->download($source);
$this->cleanup[] = new Task\Cleanup($source);
}
* @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;
}
/**
}
$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;
}
}