/** * Handle the event. * * @param ReleaseCommandsWereExecuted $event * * @return void */ public function handle(ReleaseCommandsWereExecuted $event) { if ($event->repository->processing !== $event->tag) { return; } $this->svn->at($event->location); $message = $event->tag . ' - Paddle'; $output = '>>> Executing Commands' . PHP_EOL . $this->format($event->output, $event); $output .= '>>> Adding' . PHP_EOL; list(, $_output) = $this->svn->build()->add()->safe('trunk/*')->execute(); $output .= $this->format($_output, $event); $this->svn->build()->rm()->safe('tags/' . basename($event->tag))->m(true, $message)->force()->execute(); $this->remove($event->location . '/tags/' . basename($event->tag)); $output .= '>>> Resolving' . PHP_EOL; list(, $_output) = $this->svn->build()->resolve()->accept('working')->safe('trunk')->execute(); $output .= $this->format($_output, $event); $output .= '>>> Copying' . PHP_EOL; $this->svn->build()->cp()->safe('trunk')->unsafe('tags/' . basename($event->tag))->execute(); $output .= $this->format($_output, $event); $output .= '>>> Committing' . PHP_EOL; $svn = $this->svn->build()->commit()->m(true, $message)->username($event->repository->username); if (!$event->repository->use_ssh) { $svn->password($event->repository->password); } list($success, $output) = $svn->execute($event->repository->use_ssh); $output .= $this->format($_output, $event); $output .= '>>> Committed "' . $message . '"'; event(new ReleaseWasUploaded($event->repository, $event->location, $event->tag, compact('success', 'output', 'message'))); }
/** * Handle the event. * * @param ReleaseWasDownloaded $event * * @return void */ public function handle(ReleaseWasDownloaded $event) { if ($event->repository->processing !== $event->tag) { return; } $path = storage_path('releases/' . $event->repository->getRouteKey()); $location = time() . '-' . str_random(16); if (!mkdir($path . '/' . $location, 0777, true)) { $this->release(); return; } $archive = new ZipArchive(); if (!$archive->open($event->location)) { $this->remove($path . '/' . $location); $this->release(); return; } $svn = $this->svn->at($path . '/' . $location)->build()->checkout()->unsafe(rtrim($event->repository->svn, '/'))->safe('./')->username($event->repository->username); if (!$event->repository->use_ssh) { $svn->password($event->repository->password); } list($success, $output) = $svn->execute($event->repository->use_ssh); if (!$success) { $this->release(); return; } $dir = rtrim(array_get($archive->statIndex(0), 'name'), '/'); $archive->extractTo($path . '/' . $location); $archive->close(); $this->remove($path . '/' . $location . '/trunk'); if (!rename($path . '/' . $location . '/' . $dir, $path . '/' . $location . '/trunk')) { $this->remove($path . '/' . $location); $this->release(); return; } unlink($event->location); event(new ReleaseWasExtracted($event->repository, $path . '/' . $location, $event->tag)); }
/** * Executes the command. * * @param bool $ssh * * @return [bool, string] */ public function execute($ssh = false) { return $this->svn->execute($this->command, $ssh); }