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 {
- $task = new Task\StreamFetch($source, function($bytes_pct) {
- $this->info(" %3d%% [%s>%s] \r%s",
- floor($bytes_pct*100),
- str_repeat("=", round(50*$bytes_pct)),
- str_repeat(" ", round(50*(1-$bytes_pct))),
- $bytes_pct == 1 ? "\n":""
- );
+ /* print newline only once */
+ $done = false;
+ $task = new Task\StreamFetch($source, function($bytes_pct) use(&$done) {
+ if (!$done) {
+ $this->info(" %3d%% [%s>%s] \r",
+ floor($bytes_pct*100),
+ str_repeat("=", round(50*$bytes_pct)),
+ str_repeat(" ", round(50*(1-$bytes_pct)))
+ );
+ if ($bytes_pct == 1) {
+ $done = true;
+ printf("\n");
+ }
+ }
});
}
$local = $task->run($this->verbosity());
* @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);
}
$this->source = new SourceDir\Pecl($source);
} elseif ($this->args["git"]) {
$this->source = new SourceDir\Git($source);
- } elseif (is_file("$source/parext_package.php")) {
+ } elseif (is_file("$source/pharext_package.php")) {
$this->source = include "$source/pharext_package.php";
} else {
$this->source = new SourceDir\Basic($source);