Esempio n. 1
0
 protected function applyResultToFilelist(ExecuteResult $result)
 {
     $filesModified = $this->context->getFilesModified();
     foreach ($result->getDerived() as $pattern) {
         $filesModified->add($pattern);
     }
     foreach ($result->getRemoved() as $pattern) {
         $filesModified->remove($pattern);
     }
 }
Esempio n. 2
0
 public function execute(Context $context)
 {
     // this was filled by the builder
     $filesModified = $context->getFilesModified();
     $filesDeleted = $context->getFilesDeleted();
     if (false === $context->isFullDeploy()) {
         $diff = $this->repository->diff($context->getRemoteVersion(), $context->getVersion());
         $subselectionModified = new FileCollection($context->getBuilddir());
         foreach ($diff as $fileinfo) {
             if (Status::ADDED === $fileinfo->getStatus()) {
                 $subselectionModified[] = $fileinfo->getPathname();
             } elseif (Status::MODIFIED === $fileinfo->getStatus()) {
                 $subselectionModified[] = $fileinfo->getPathname();
             } elseif (Status::DELETED === $fileinfo->getStatus()) {
                 $filesDeleted->add($fileinfo->getPathname(), true);
             } else {
                 // @todo handle other cases if they actually exist
             }
         }
         foreach ($this->derivedFiles as $derivable) {
             $source = $derivable['source'];
             $derived = $derivable['derived'];
             if ($subselectionModified->has($source)) {
                 $subselectionModified->add($derived);
             }
         }
         // only keep files that are changed
         $filesModified->intersect($subselectionModified);
         //            if (0 === count($filesAdded) && count($subselectionAdded) > 0) {
         //                // hmm.. so files have changed but nothing to deploy
         //                // it looks like we forgot to specify some derived files
         //                // @todo inform the user about this?
         //            }
         // @todo we could also check here if all files are accounted for (maybe
         //       some files were deleted and not told to us by setting it in
         //       the `removes` config?) in other words: file_exists on all files?
     } else {
         foreach ($this->derivedFiles as $derivable) {
             $source = $derivable['source'];
             $derived = $derivable['derived'];
             if ($filesModified->has($source)) {
                 $filesModified->add($derived);
             }
         }
     }
     // never upload the conveyor configuration!
     $filesModified->remove('conveyor.yml');
     // validate result, throw exception when we have nothing to deploy
     if (0 === count($filesModified) && 0 === count($filesDeleted)) {
         throw new EmptyChangesetException();
     }
     $context->setFilesModified($filesModified);
     $context->setFilesDeleted($filesDeleted);
 }
Esempio n. 3
0
 public function execute(Context $context)
 {
     $filesModified = $context->getFilesModified();
     $filesDeleted = $context->getFilesDeleted();
     if ($this->io) {
         $this->io->write('');
         if (true === $context->isSimulate()) {
             $this->io->write(sprintf('Simulating upload to <info>%s</info>', $context->getTarget()));
         } else {
             $this->io->write(sprintf('Uploading to <info>%s</info>', $context->getTarget()));
         }
         $this->io->write(sprintf(' - Uploading to <comment>%s</comment>', $this->transporter->getHost()));
         $this->io->increaseIndention(3);
     }
     $this->uploadFiles($filesModified->toArray(), $context);
     $this->removeFiles($filesDeleted->toArray(), $context);
     if ($this->io) {
         if (true === $this->showProgress) {
             // clear last line, because it was a overwrite
             $this->io->write('');
         }
         $this->io->decreaseIndention(3);
     }
 }
Esempio n. 4
0
 /**
  * Makes sure we don't upload to locations that are shared
  *
  * @param Context $context
  */
 protected function filterSharedFilesAndFolders(Context $context)
 {
     $this->sharedFiles = new FileCollection($context->getBuilddir());
     $filesModified = $context->getFilesModified();
     $shared = (array) $this->options['shared'];
     foreach ($shared as $fileOrFolder) {
         if ($filesModified->has($fileOrFolder)) {
             $filesModified->remove($fileOrFolder);
             $this->sharedFiles->add($fileOrFolder);
         }
     }
 }