namespace pharext\SourceDir;
-use pharext\Command;
+use pharext\Cli\Args;
+use pharext\License;
use pharext\SourceDir;
/**
*/
class Git implements \IteratorAggregate, SourceDir
{
- /**
- * The Packager command
- * @var pharext\Command
- */
- private $cmd;
+ use License;
/**
* Base directory
* @inheritdoc
* @see \pharext\SourceDir::__construct()
*/
- public function __construct(Command $cmd, $path) {
- $this->cmd = $cmd;
+ public function __construct($path) {
$this->path = $path;
}
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
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()