Пример #1
0
 /**
  * Sets the deployment to pending.
  */
 private function setDeploymentStatus()
 {
     $this->deployment->status = Deployment::PENDING;
     $this->deployment->started_at = date('Y-m-d H:i:s');
     $this->deployment->project_id = $this->project->id;
     if (Auth::check()) {
         $this->deployment->user_id = Auth::user()->id;
     } else {
         $this->deployment->is_webhook = true;
     }
     $this->deployment->committer = $this->deployment->committer ?: Deployment::LOADING;
     $this->deployment->commit = $this->deployment->commit ?: Deployment::LOADING;
     $this->deployment->save();
     $this->deployment->project->status = Project::PENDING;
     $this->deployment->project->save();
 }
Пример #2
0
 /**
  * Clones the repository locally to get the latest log entry and updates
  * the deployment model.
  */
 private function updateRepoInfo()
 {
     $commit = $this->deployment->commit === Deployment::LOADING ? null : $this->deployment->commit;
     $process = new Process('tools.GetCommitDetails', ['mirror_path' => $this->deployment->project->mirrorPath(), 'git_reference' => $commit ?: $this->deployment->branch]);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException('Could not get repository info - ' . $process->getErrorOutput());
     }
     $git_info = $process->getOutput();
     list($commit, $committer, $email) = explode("\t", $git_info);
     $this->deployment->commit = $commit;
     $this->deployment->committer = trim($committer);
     $this->deployment->committer_email = trim($email);
     if (!$this->deployment->user_id && !$this->deployment->source) {
         $user = User::where('email', $this->deployment->committer_email)->first();
         if ($user) {
             $this->deployment->user_id = $user->id;
         }
     }
     $this->deployment->save();
 }