a16b1e67769726e26c912b7d9883edcd2635dca9
3 namespace pharext\SourceDir
;
9 * Extension source directory which is a git repo
11 class Git
implements \IteratorAggregate
, SourceDir
14 * The Packager command
15 * @var pharext\Command
27 * @see \pharext\SourceDir::__construct()
29 public function __construct(Command
$cmd, $path) {
36 * @see \pharext\SourceDir::getBaseDir()
38 public function getBaseDir() {
43 * Generate a list of files by `git ls-files`
46 private function generateFiles() {
49 if (($pipe = popen("git ls-files", "r"))) {
50 while (!feof($pipe)) {
51 if (strlen($file = trim(fgets($pipe)))) {
52 if ($this->cmd
->getArgs()->verbose
) {
53 $this->cmd
->info("Packaging %s\n", $file);
55 if (!($realpath = realpath($file))) {
56 $this->cmd
->error("File %s does not exist\n", $file);
67 * Implements IteratorAggregate
68 * @see IteratorAggregate::getIterator()
70 public function getIterator() {
71 return $this->generateFiles();