예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function request($method, $uri, $body, $headers = [], array $options = [])
 {
     $this->log->begin("{$method} {$uri}");
     try {
         $response = parent::request($method, $uri, $body, $headers, $options);
     } catch (\Exception $ex) {
         $this->log->endError($ex->getCode());
         throw $ex;
     }
     $this->log->endHttpStatus($response->getStatusCode());
     return $response;
 }
예제 #2
0
 /**
  * Label open issues from past due milestones as overdue.
  *
  * @param string $label The name of the label to apply to the issues when overdue.
  */
 public function labelOverdue($label = 'Overdue')
 {
     $this->log->begin("Marking issues overdue on {$this->fromRepo}");
     // Check to see if the label exists.
     $labelResponse = $this->api()->get("/repos/{$this->fromRepo}/labels/" . rawurlencode($label));
     if (!$labelResponse->isSuccessful()) {
         $this->log->endError("Could not find label: {$label}");
         return;
     }
     $milestones = $this->getMilestones($this->getFromRepo());
     $now = new \DateTime();
     foreach ($milestones as $milestone) {
         $due = new \DateTime($milestone['due_on']);
         if ($due > $now || $milestone['open_issues'] <= 0) {
             continue;
         }
         // The milestone has open issues so get them.
         $issues = $this->api()->get("/repos/{$this->fromRepo}/issues", ['milestone' => $milestone['number']]);
         if (!$issues->isSuccessful()) {
             $this->log->error($issues['message']);
             continue;
         }
         foreach ($issues->getBody() as $issue) {
             if (in_array($label, array_column($issue['labels'], 'name'))) {
                 continue;
             }
             $r = $this->api()->post("/repos/{$this->fromRepo}/issues/{$issue['number']}/labels", [$label]);
             if ($r->isSuccessful()) {
                 $this->log->message("#{$issue['number']} {$issue['title']}: {$label}", true);
             }
         }
     }
     $this->log->end('Done');
 }
예제 #3
0
 /**
  * The {@link LogFormatter} should not take a negative max level.
  *
  * @expectedException \InvalidArgumentException
  */
 public function testBadMaxLevel()
 {
     $log = new LogFormatter();
     $log->setMaxLevel(-1);
 }