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); }
protected function compareRemoteVersionBuild(Context $context) { if ($context->isFullDeploy()) { return true; } if ($context->getVersion()->equals($context->getRemoteVersion())) { $this->io->write('Remote version is already up-to-date.', true); return false; } elseif (1 === $this->repository->versionCompare($context->getRemoteVersion(), $context->getVersion())) { if ($context->isForce()) { $answer = true; } else { $answer = $this->io->askConfirmation(sprintf('Remote version (%s) is newer than the selected version (%s). ' . 'Would you like to continue as full deploy? (Y/n): ', $context->getRemoteVersion()->getBuild(), $context->getVersion()->getBuild()), 'Y'); } if ($answer) { $context->setFullDeploy(true); } else { return false; } } return true; }
protected function validateRemoteVersionFile(Context $context) { if ($context->isFullDeploy()) { return; } $versionFile = FilePath::join($this->transporter->getPath(), $context->getStrategy()->getCurrentReleasePath(), $this->remoteInfoFile); if (false == $this->transporter->exists($versionFile)) { if ($context->isForce()) { $answer = true; } else { $answer = $this->io->askConfirmation(sprintf('Remote version information not found. Would you like to do a full deploy? (Y/n): '), 'Y'); } if ($answer) { $context->setFullDeploy(true); } else { return false; } } return true; }
/** * Copies the latest version server-side to the uploaddir, * in case this is a incremental deploy. * * @param \Webcreate\Conveyor\Context $context */ protected function prepareUploadPath($context) { $basepath = $this->transporter->getPath(); $uploadPath = $basepath . '/' . $this->getUploadPath($context->getVersion()); $currentReleasePath = $basepath . '/' . $this->getCurrentReleasePath() . '/'; if (false === $context->isFullDeploy()) { // add some white space to the output $this->io->write(''); $this->transporter->copy($currentReleasePath, $uploadPath); } }