9c51c7d25febbbb651eacb9d7e47251f01ab883b
3 namespace pharext\SourceDir
;
9 use pharext\PackageInfo
;
10 use pharext\SourceDir
;
14 * Extension source directory which is a git repo
16 class Git
implements \IteratorAggregate
, SourceDir
29 * @see \pharext\SourceDir::__construct()
31 public function __construct($path) {
37 * @see \pharext\SourceDir::getBaseDir()
39 public function getBaseDir() {
47 public function getPackageInfo() {
48 return $this->findPackageInfo($this->getBaseDir());
55 public function getLicense() {
56 if (($file = $this->findLicense($this->getBaseDir()))) {
57 return $this->readLicense($file);
66 public function getArgs() {
73 public function setArgs(Args
$args) {
77 * Generate a list of files by `git ls-files`
80 private function generateFiles() {
83 if (($pipe = popen("git ls-tree -r --name-only HEAD", "r"))) {
84 $path = realpath($this->path
);
85 while (!feof($pipe)) {
86 if (strlen($file = trim(fgets($pipe)))) {
87 /* there may be symlinks, so no realpath here */
97 * Implements IteratorAggregate
98 * @see IteratorAggregate::getIterator()
100 public function getIterator() {
101 return $this->generateFiles();