3 namespace pharext\SourceDir
;
10 * Extension source directory which is a git repo
12 class Git
implements \IteratorAggregate
, SourceDir
22 * @see \pharext\SourceDir::__construct()
24 public function __construct($path) {
30 * @see \pharext\SourceDir::getBaseDir()
32 public function getBaseDir() {
40 public function getPackageInfo() {
48 public function getArgs() {
55 public function setArgs(Args
$args) {
59 * Generate a list of files by `git ls-files`
62 private function generateFiles() {
65 if (($pipe = popen("git ls-tree -r --name-only HEAD", "r"))) {
66 $path = realpath($this->path
);
67 while (!feof($pipe)) {
68 if (strlen($file = trim(fgets($pipe)))) {
69 /* there may be symlinks, so no realpath here */
79 * Implements IteratorAggregate
80 * @see IteratorAggregate::getIterator()
82 public function getIterator() {
83 return $this->generateFiles();