3 namespace pharext\SourceDir
;
10 * Extension source directory which is a git repo
12 class Git
implements \IteratorAggregate
, SourceDir
24 * @see \pharext\SourceDir::__construct()
26 public function __construct($path) {
32 * @see \pharext\SourceDir::getBaseDir()
34 public function getBaseDir() {
42 public function getPackageInfo() {
50 public function getLicense() {
51 if (($file = $this->findLicense($this->getBaseDir()))) {
52 return $this->readLicense($file);
61 public function getArgs() {
68 public function setArgs(Args
$args) {
72 * Generate a list of files by `git ls-files`
75 private function generateFiles() {
78 if (($pipe = popen("git ls-tree -r --name-only HEAD", "r"))) {
79 $path = realpath($this->path
);
80 while (!feof($pipe)) {
81 if (strlen($file = trim(fgets($pipe)))) {
82 /* there may be symlinks, so no realpath here */
92 * Implements IteratorAggregate
93 * @see IteratorAggregate::getIterator()
95 public function getIterator() {
96 return $this->generateFiles();