Exemple #1
0
 public function testGetFilename()
 {
     $fileInfo = new VcsFileInfo('conveyor.yml', array('master', VcsFileInfo::BRANCH));
     $this->assertEquals('conveyor.yml', $fileInfo->getFilename());
     $fileInfo = new VcsFileInfo('path/to/file', array('master', VcsFileInfo::BRANCH));
     $this->assertEquals('file', $fileInfo->getFilename());
 }
Exemple #2
0
 /**
  * (non-PHPdoc)
  * @see Webcreate\Vcs.VcsInterface::ls()
  */
 public function ls($path)
 {
     if (!$this->hasCheckout) {
         $this->checkout();
     }
     if ($path == '/') {
         $path = '';
     }
     if (false === file_exists($this->cwd . '/' . $path)) {
         throw new NotFoundException(sprintf('The path \'%s\' is not found in %s', $path, $this->cwd));
     }
     $finder = new Finder();
     $files = $finder->in($this->cwd . '/' . $path)->exclude(".git")->ignoreDotFiles(false)->depth('== 0');
     $filelist = array();
     $entries = array();
     foreach ($files as $file) {
         $log = $this->log(($path ? $path . '/' : '') . $file->getRelativePathname(), null, 1);
         $commit = reset($log);
         $kind = $file->isDir() ? VcsFileInfo::DIR : VcsFileInfo::FILE;
         $file = new VcsFileInfo($file->getFilename(), $this->getHead(), $kind);
         $file->setCommit($commit);
         $entries[] = $file;
     }
     return $entries;
 }