X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FSourceDir%2FGit.php;h=62dc24f9e5162cfde0cf7ff3d6380c4e5a7a2875;hb=e44f0adc7b18845a2cd3dc63fdab5d9bcdc10f76;hp=a16b1e67769726e26c912b7d9883edcd2635dca9;hpb=26683702fdc53d2431ae2bc5081439ac12685d1b;p=pharext%2Fpharext diff --git a/src/pharext/SourceDir/Git.php b/src/pharext/SourceDir/Git.php index a16b1e6..62dc24f 100644 --- a/src/pharext/SourceDir/Git.php +++ b/src/pharext/SourceDir/Git.php @@ -2,7 +2,8 @@ namespace pharext\SourceDir; -use pharext\Command; +use pharext\Cli\Args; +use pharext\License; use pharext\SourceDir; /** @@ -10,11 +11,7 @@ use pharext\SourceDir; */ class Git implements \IteratorAggregate, SourceDir { - /** - * The Packager command - * @var pharext\Command - */ - private $cmd; + use License; /** * Base directory @@ -26,8 +23,7 @@ class Git implements \IteratorAggregate, SourceDir * @inheritdoc * @see \pharext\SourceDir::__construct() */ - public function __construct(Command $cmd, $path) { - $this->cmd = $cmd; + public function __construct($path) { $this->path = $path; } @@ -38,7 +34,40 @@ class Git implements \IteratorAggregate, SourceDir public function getBaseDir() { return $this->path; } - + + /** + * @inheritdoc + * @return array + */ + public function getPackageInfo() { + return []; + } + + /** + * @inheritdoc + * @return string + */ + public function getLicense() { + if (($file = $this->findLicense($this->getBaseDir()))) { + return $this->readLicense($file); + } + return "UNKNOWN"; + } + + /** + * @inheritdoc + * @return array + */ + public function getArgs() { + return []; + } + + /** + * @inheritdoc + */ + public function setArgs(Args $args) { + } + /** * Generate a list of files by `git ls-files` * @return Generator @@ -46,23 +75,19 @@ class Git implements \IteratorAggregate, SourceDir private function generateFiles() { $pwd = getcwd(); chdir($this->path); - if (($pipe = popen("git ls-files", "r"))) { + if (($pipe = popen("git ls-tree -r --name-only HEAD", "r"))) { + $path = realpath($this->path); while (!feof($pipe)) { if (strlen($file = trim(fgets($pipe)))) { - if ($this->cmd->getArgs()->verbose) { - $this->cmd->info("Packaging %s\n", $file); - } - if (!($realpath = realpath($file))) { - $this->cmd->error("File %s does not exist\n", $file); - } - yield $realpath; + /* there may be symlinks, so no realpath here */ + yield "$path/$file"; } } pclose($pipe); } chdir($pwd); } - + /** * Implements IteratorAggregate * @see IteratorAggregate::getIterator()