示例#1
0
 private static function findSortOrder($run, $mode_id, $revision)
 {
     $version_control = VersionControl::forMode($mode_id);
     $j = 0;
     while (True) {
         if ($j++ > 30) {
             throw new Exception("There shouldn't be too many runs in between");
         }
         if (!$run->isBuildInfoComplete()) {
             throw new Exception("Encountered an incomplete run.");
         }
         $build = Build::withRunAndMode($run->id, $mode_id);
         // We can safely ignore runs that have no results with the requested mode_id
         if (!$build) {
             $run = $run->next();
             continue;
         }
         // We skip to the next run, if revisions are the same.
         // To make sure that new runs are shown after existing ones.
         if ($version_control->equal($build->revision(), $revision)) {
             $run = $run->next();
             continue;
         }
         // Using version control take a peek if the revision
         // is later/earlier than this one.
         if ($version_control->isAfter($build->revision(), $revision)) {
             return $run->sort_order();
         }
         $run = $run->next();
     }
 }
 public static function retriggerable($machine_id, $mode_id)
 {
     $retrigger = RetriggerController::fromMachine($machine_id, $mode_id);
     if (count($retrigger->tasks) == 0) {
         return false;
     }
     try {
         VersionControl::forMode($mode_id);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
<?php

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once "../internals.php";
require_once "../lib/DB/Regression.php";
require_once "../lib/VersionControl.php";
init_database();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$id = (int) $request->id;
$regression = Regression::FromId($id);
$build = $regression->build() or throw_exception("Couldn't retrieve the build of regression {$id}.");
$prev_build = $regression->prev_build() or throw_exception("Couldn't retrieve the prev_build of regression {$id}.");
$regression->build()->revision();
$regression->prev_build()->revision();
$versionControl = VersionControl::forMode($build->mode_id());
$revisions = $versionControl->revisions($prev_build->revision(), $build->revision());
$data = array();
foreach ($revisions as $revision) {
    $data[] = array("author" => $revision->author, "date" => $revision->date, "revision" => $revision->revision, "message" => $revision->message);
}
echo json_encode($data);