Esempio n. 1
0
 public function updateCommit(Commit $commit)
 {
     $stmt = $this->db->prepare('UPDATE `commit` SET status = :status, output = :output, build_date = CURRENT_TIMESTAMP WHERE slug = :slug AND sha = :sha');
     $stmt->bindValue(':slug', $commit->getProject()->getSlug(), SQLITE3_TEXT);
     $stmt->bindValue(':sha', $commit->getSha(), SQLITE3_TEXT);
     $stmt->bindValue(':status', $commit->getStatusCode(), SQLITE3_TEXT);
     $stmt->bindValue(':output', $commit->getOutput(), SQLITE3_TEXT);
     if (false === $stmt->execute()) {
         throw new \RuntimeException(sprintf('Unable to save build "%s@%s".', $commit->getProject()->getName(), $commit->getSha()));
     }
 }
Esempio n. 2
0
 public function testSha()
 {
     $commit = new Commit(new Project('Twig'), '7d78d5f7a8c039059046d6c5e1d7f66765bd91c7');
     $this->assertEquals('7d78d5f7a8c039059046d6c5e1d7f66765bd91c7', $commit->getSha());
     $this->assertEquals('7d78d5', $commit->getShortSha());
 }
Esempio n. 3
0
 /**
  * @param Commit $commit
  *
  * @return string
  */
 protected function getStatusEndpointUrl(Commit $commit)
 {
     return $this->host . "/repos/" . $this->repo . "/statuses/" . $commit->getSha();
 }
Esempio n. 4
0
 /**
  * Update the commits information.
  *
  * The commit is identified by its sha hash.
  *
  * @param Commit $commit
  *
  * @return StorageInterface $this
  */
 public function updateCommit(Commit $commit)
 {
     $stmt = $this->db->prepare('UPDATE `commit` SET status = :status, output = :output, build_date = :current_date WHERE slug = :slug AND sha = :sha');
     $stmt->bindValue(':slug', $commit->getProject()->getSlug(), \PDO::PARAM_STR);
     $stmt->bindValue(':sha', $commit->getSha(), \PDO::PARAM_STR);
     $stmt->bindValue(':status', $commit->getStatusCode(), \PDO::PARAM_STR);
     $stmt->bindValue(':output', $commit->getOutput(), \PDO::PARAM_STR);
     $stmt->bindValue(':current_date', date('Y-m-d H:i:s'), \PDO::PARAM_STR);
     if (false === $stmt->execute()) {
         // @codeCoverageIgnoreStart
         throw new \RuntimeException(sprintf('Unable to save build "%s@%s".', $commit->getProject()->getName(), $commit->getSha()));
         // @codeCoverageIgnoreEnd
     }
 }
Esempio n. 5
0
 protected function getPlaceholders(Commit $commit)
 {
     $project = $commit->getProject();
     return array('%slug%' => $project->getSlug(), '%name%' => $project->getName(), '%status%' => $commit->getStatus(), '%status_code%' => $commit->getStatusCode(), '%STATUS%' => strtoupper($commit->getStatus()), '%sha%' => $commit->getSha(), '%short_sha%' => $commit->getShortSha(), '%author%' => $commit->getAuthor(), '%message%' => $commit->getMessage(), '%output%' => $commit->getOutput());
 }