6 * Extension source directory which is a git repo
8 class GitSourceDir
implements \IteratorAggregate
, SourceDir
11 * The Packager command
12 * @var pharext\Command
24 * @see \pharext\SourceDir::__construct()
26 public function __construct(Command
$cmd, $path) {
33 * @see \pharext\SourceDir::getBaseDir()
35 public function getBaseDir() {
40 * Generate a list of files by `git ls-files`
43 private function generateFiles() {
46 if (($pipe = popen("git ls-files", "r"))) {
47 while (!feof($pipe)) {
48 if (strlen($file = trim(fgets($pipe)))) {
49 if ($this->cmd
->getArgs()->verbose
) {
50 $this->cmd
->info("Packaging %s\n", $file);
52 if (!($realpath = realpath($file))) {
53 $this->cmd
->error("File %s does not exist\n", $file);
64 * Implements IteratorAggregate
65 * @see IteratorAggregate::getIterator()
67 public function getIterator() {
68 return $this->generateFiles();