mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Move build statuses to a constants class
Summary: No functional changes here, just lifting this out to make room for activities, heeding lint warnings along the way. Test Plan: before: ```lang=bash $ grep -Rn "HarbormasterBuild::" * src/applications/harbormaster/storage/HarbormasterBuildable.php:169: $build = HarbormasterBuild::initializeNewBuild($viewer) src/applications/harbormaster/storage/HarbormasterBuildable.php:173: ->setBuildStatus(HarbormasterBuild::STATUS_PENDING); src/applications/harbormaster/controller/HarbormasterStepEditController.php:242: $variables = HarbormasterBuild::getAvailableBuildVariables(); src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:200: 'fa-dot-circle-o '.HarbormasterBuild::getBuildStatusColor($status), src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:201: HarbormasterBuild::getBuildStatusName($status)); src/applications/harbormaster/controller/HarbormasterBuildableViewController.php:203: $item->addAttribute(HarbormasterBuild::getBuildStatusName($status)); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:584: HarbormasterBuild::getBuildStatusName($status); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:585: $icon = HarbormasterBuild::getBuildStatusIcon($status); src/applications/harbormaster/controller/HarbormasterBuildViewController.php:586: $color = HarbormasterBuild::getBuildStatusColor($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:135: $status_name = HarbormasterBuild::getBuildStatusName($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:136: $icon = HarbormasterBuild::getBuildStatusIcon($status); src/applications/harbormaster/event/HarbormasterUIEventListener.php:137: $color = HarbormasterBuild::getBuildStatusColor($status); src/applications/harbormaster/conduit/HarbormasterQueryBuildsConduitAPIMethod.php:78: 'buildStatusName' => HarbormasterBuild::getBuildStatusName($status), src/applications/harbormaster/engine/HarbormasterBuildEngine.php:66: $build->setBuildStatus(HarbormasterBuild::STATUS_ERROR); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:109: $build->setBuildStatus(HarbormasterBuild::STATUS_ABORTED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:113: if (($build->getBuildStatus() == HarbormasterBuild::STATUS_PENDING) || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:116: $build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:121: $build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:126: $build->setBuildStatus(HarbormasterBuild::STATUS_PAUSED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:132: if ($build->getBuildStatus() == HarbormasterBuild::STATUS_BUILDING) { src/applications/harbormaster/engine/HarbormasterBuildEngine.php:246: $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:254: $build->setBuildStatus(HarbormasterBuild::STATUS_PASSED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:290: $build->setBuildStatus(HarbormasterBuild::STATUS_DEADLOCKED); src/applications/harbormaster/engine/HarbormasterBuildEngine.php:446: if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) { src/applications/harbormaster/engine/HarbormasterBuildEngine.php:449: if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:450: $build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR || src/applications/harbormaster/engine/HarbormasterBuildEngine.php:451: $build->getBuildStatus() == HarbormasterBuild::STATUS_DEADLOCKED) { ``` after: ```lang=bash $ grep -Rn "HarbormasterBuild::" * src/applications/harbormaster/storage/HarbormasterBuildable.php:169: $build = HarbormasterBuild::initializeNewBuild($viewer) src/applications/harbormaster/controller/HarbormasterStepEditController.php:242: $variables = HarbormasterBuild::getAvailableBuildVariables(); ``` ran a manual build as a sanity check Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D16348
This commit is contained in:
parent
2c55a4ad72
commit
42b81a8090
11 changed files with 168 additions and 160 deletions
|
@ -1131,6 +1131,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildQuery' => 'applications/harbormaster/query/HarbormasterBuildQuery.php',
|
||||
'HarbormasterBuildRequest' => 'applications/harbormaster/engine/HarbormasterBuildRequest.php',
|
||||
'HarbormasterBuildSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildSearchEngine.php',
|
||||
'HarbormasterBuildStatus' => 'applications/harbormaster/constants/HarbormasterBuildStatus.php',
|
||||
'HarbormasterBuildStatusDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildStatusDatasource.php',
|
||||
'HarbormasterBuildStep' => 'applications/harbormaster/storage/configuration/HarbormasterBuildStep.php',
|
||||
'HarbormasterBuildStepCoreCustomField' => 'applications/harbormaster/customfield/HarbormasterBuildStepCoreCustomField.php',
|
||||
|
@ -5687,6 +5688,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'HarbormasterBuildRequest' => 'Phobject',
|
||||
'HarbormasterBuildSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'HarbormasterBuildStatus' => 'Phobject',
|
||||
'HarbormasterBuildStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'HarbormasterBuildStep' => array(
|
||||
'HarbormasterDAO',
|
||||
|
|
|
@ -66,6 +66,7 @@ final class HarbormasterQueryBuildsConduitAPIMethod
|
|||
$id = $build->getID();
|
||||
$uri = '/harbormaster/build/'.$id.'/';
|
||||
$status = $build->getBuildStatus();
|
||||
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||
|
||||
$data[] = array(
|
||||
'id' => $id,
|
||||
|
@ -75,7 +76,7 @@ final class HarbormasterQueryBuildsConduitAPIMethod
|
|||
'buildablePHID' => $build->getBuildablePHID(),
|
||||
'buildPlanPHID' => $build->getBuildPlanPHID(),
|
||||
'buildStatus' => $status,
|
||||
'buildStatusName' => HarbormasterBuild::getBuildStatusName($status),
|
||||
'buildStatusName' => $status_name,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
final class HarbormasterBuildStatus extends Phobject {
|
||||
|
||||
/**
|
||||
* Not currently being built.
|
||||
*/
|
||||
const STATUS_INACTIVE = 'inactive';
|
||||
|
||||
/**
|
||||
* Pending pick up by the Harbormaster daemon.
|
||||
*/
|
||||
const STATUS_PENDING = 'pending';
|
||||
|
||||
/**
|
||||
* Current building the buildable.
|
||||
*/
|
||||
const STATUS_BUILDING = 'building';
|
||||
|
||||
/**
|
||||
* The build has passed.
|
||||
*/
|
||||
const STATUS_PASSED = 'passed';
|
||||
|
||||
/**
|
||||
* The build has failed.
|
||||
*/
|
||||
const STATUS_FAILED = 'failed';
|
||||
|
||||
/**
|
||||
* The build has aborted.
|
||||
*/
|
||||
const STATUS_ABORTED = 'aborted';
|
||||
|
||||
/**
|
||||
* The build encountered an unexpected error.
|
||||
*/
|
||||
const STATUS_ERROR = 'error';
|
||||
|
||||
/**
|
||||
* The build has been paused.
|
||||
*/
|
||||
const STATUS_PAUSED = 'paused';
|
||||
|
||||
/**
|
||||
* The build has been deadlocked.
|
||||
*/
|
||||
const STATUS_DEADLOCKED = 'deadlocked';
|
||||
|
||||
|
||||
/**
|
||||
* Get a human readable name for a build status constant.
|
||||
*
|
||||
* @param const Build status constant.
|
||||
* @return string Human-readable name.
|
||||
*/
|
||||
public static function getBuildStatusName($status) {
|
||||
$map = self::getBuildStatusMap();
|
||||
return idx($map, $status, pht('Unknown ("%s")', $status));
|
||||
}
|
||||
|
||||
public static function getBuildStatusMap() {
|
||||
return array(
|
||||
self::STATUS_INACTIVE => pht('Inactive'),
|
||||
self::STATUS_PENDING => pht('Pending'),
|
||||
self::STATUS_BUILDING => pht('Building'),
|
||||
self::STATUS_PASSED => pht('Passed'),
|
||||
self::STATUS_FAILED => pht('Failed'),
|
||||
self::STATUS_ABORTED => pht('Aborted'),
|
||||
self::STATUS_ERROR => pht('Unexpected Error'),
|
||||
self::STATUS_PAUSED => pht('Paused'),
|
||||
self::STATUS_DEADLOCKED => pht('Deadlocked'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getBuildStatusIcon($status) {
|
||||
switch ($status) {
|
||||
case self::STATUS_INACTIVE:
|
||||
case self::STATUS_PENDING:
|
||||
return PHUIStatusItemView::ICON_OPEN;
|
||||
case self::STATUS_BUILDING:
|
||||
return PHUIStatusItemView::ICON_RIGHT;
|
||||
case self::STATUS_PASSED:
|
||||
return PHUIStatusItemView::ICON_ACCEPT;
|
||||
case self::STATUS_FAILED:
|
||||
return PHUIStatusItemView::ICON_REJECT;
|
||||
case self::STATUS_ABORTED:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_ERROR:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_PAUSED:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_DEADLOCKED:
|
||||
return PHUIStatusItemView::ICON_WARNING;
|
||||
default:
|
||||
return PHUIStatusItemView::ICON_QUESTION;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBuildStatusColor($status) {
|
||||
switch ($status) {
|
||||
case self::STATUS_INACTIVE:
|
||||
return 'dark';
|
||||
case self::STATUS_PENDING:
|
||||
case self::STATUS_BUILDING:
|
||||
return 'blue';
|
||||
case self::STATUS_PASSED:
|
||||
return 'green';
|
||||
case self::STATUS_FAILED:
|
||||
case self::STATUS_ABORTED:
|
||||
case self::STATUS_ERROR:
|
||||
case self::STATUS_DEADLOCKED:
|
||||
return 'red';
|
||||
case self::STATUS_PAUSED:
|
||||
return 'dark';
|
||||
default:
|
||||
return 'bluegrey';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -581,9 +581,9 @@ final class HarbormasterBuildViewController
|
|||
} else {
|
||||
$status = $build->getBuildStatus();
|
||||
$status_name =
|
||||
HarbormasterBuild::getBuildStatusName($status);
|
||||
$icon = HarbormasterBuild::getBuildStatusIcon($status);
|
||||
$color = HarbormasterBuild::getBuildStatusColor($status);
|
||||
HarbormasterBuildStatus::getBuildStatusName($status);
|
||||
$icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||
$color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||
}
|
||||
|
||||
$item->setTarget($status_name);
|
||||
|
|
|
@ -196,11 +196,10 @@ final class HarbormasterBuildableViewController
|
|||
->setHref($view_uri);
|
||||
|
||||
$status = $build->getBuildStatus();
|
||||
$item->setStatusIcon(
|
||||
'fa-dot-circle-o '.HarbormasterBuild::getBuildStatusColor($status),
|
||||
HarbormasterBuild::getBuildStatusName($status));
|
||||
|
||||
$item->addAttribute(HarbormasterBuild::getBuildStatusName($status));
|
||||
$status_color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||
$item->setStatusIcon('fa-dot-circle-o '.$status_color, $status_name);
|
||||
$item->addAttribute($status_name);
|
||||
|
||||
if ($build->isRestarting()) {
|
||||
$item->addIcon('fa-repeat', pht('Restarting'));
|
||||
|
|
|
@ -63,7 +63,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
// If any exception is raised, the build is marked as a failure and the
|
||||
// exception is re-thrown (this ensures we don't leave builds in an
|
||||
// inconsistent state).
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_ERROR);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_ERROR);
|
||||
$build->save();
|
||||
|
||||
$lock->unlock();
|
||||
|
@ -106,30 +106,30 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
private function updateBuild(HarbormasterBuild $build) {
|
||||
if ($build->isAborting()) {
|
||||
$this->releaseAllArtifacts($build);
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_ABORTED);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_ABORTED);
|
||||
$build->save();
|
||||
}
|
||||
|
||||
if (($build->getBuildStatus() == HarbormasterBuild::STATUS_PENDING) ||
|
||||
if (($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_PENDING) ||
|
||||
($build->isRestarting())) {
|
||||
$this->restartBuild($build);
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_BUILDING);
|
||||
$build->save();
|
||||
}
|
||||
|
||||
if ($build->isResuming()) {
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_BUILDING);
|
||||
$build->save();
|
||||
}
|
||||
|
||||
if ($build->isPausing() && !$build->isComplete()) {
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_PAUSED);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PAUSED);
|
||||
$build->save();
|
||||
}
|
||||
|
||||
$build->deleteUnprocessedCommands();
|
||||
|
||||
if ($build->getBuildStatus() == HarbormasterBuild::STATUS_BUILDING) {
|
||||
if ($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_BUILDING) {
|
||||
$this->updateBuildSteps($build);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
|
||||
// If any step failed, fail the whole build, then bail.
|
||||
if (count($failed)) {
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_FAILED);
|
||||
$build->save();
|
||||
return;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
// If every step is complete, we're done with this build. Mark it passed
|
||||
// and bail.
|
||||
if (count($complete) == count($steps)) {
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_PASSED);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_PASSED);
|
||||
$build->save();
|
||||
return;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
if (!$runnable && !$waiting && !$underway) {
|
||||
// This means the build is deadlocked, and the user has configured
|
||||
// circular dependencies.
|
||||
$build->setBuildStatus(HarbormasterBuild::STATUS_DEADLOCKED);
|
||||
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_DEADLOCKED);
|
||||
$build->save();
|
||||
return;
|
||||
}
|
||||
|
@ -443,14 +443,14 @@ final class HarbormasterBuildEngine extends Phobject {
|
|||
$all_pass = true;
|
||||
$any_fail = false;
|
||||
foreach ($buildable->getBuilds() as $build) {
|
||||
if ($build->getBuildStatus() != HarbormasterBuild::STATUS_PASSED) {
|
||||
if ($build->getBuildStatus() != HarbormasterBuildStatus::STATUS_PASSED) {
|
||||
$all_pass = false;
|
||||
}
|
||||
if ($build->getBuildStatus() == HarbormasterBuild::STATUS_FAILED ||
|
||||
$build->getBuildStatus() == HarbormasterBuild::STATUS_ERROR ||
|
||||
$build->getBuildStatus() == HarbormasterBuild::STATUS_DEADLOCKED) {
|
||||
$any_fail = true;
|
||||
}
|
||||
$any_fail = in_array($build->getBuildStatus(), array(
|
||||
HarbormasterBuildStatus::STATUS_FAILED,
|
||||
HarbormasterBuildStatus::STATUS_ERROR,
|
||||
HarbormasterBuildStatus::STATUS_DEADLOCKED,
|
||||
));
|
||||
}
|
||||
|
||||
if ($any_fail) {
|
||||
|
|
|
@ -132,9 +132,9 @@ final class HarbormasterUIEventListener
|
|||
}
|
||||
|
||||
$status = $build->getBuildStatus();
|
||||
$status_name = HarbormasterBuild::getBuildStatusName($status);
|
||||
$icon = HarbormasterBuild::getBuildStatusIcon($status);
|
||||
$color = HarbormasterBuild::getBuildStatusColor($status);
|
||||
$status_name = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||
$icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||
$color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||
|
||||
$item->setIcon($icon, $color, $status_name);
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ final class HarbormasterBuildSearchEngine
|
|||
|
||||
$status = $build->getBuildStatus();
|
||||
|
||||
$status_icon = HarbormasterBuild::getBuildStatusIcon($status);
|
||||
$status_color = HarbormasterBuild::getBuildStatusColor($status);
|
||||
$status_label = HarbormasterBuild::getBuildStatusName($status);
|
||||
$status_icon = HarbormasterBuildStatus::getBuildStatusIcon($status);
|
||||
$status_color = HarbormasterBuildStatus::getBuildStatusColor($status);
|
||||
$status_label = HarbormasterBuildStatus::getBuildStatusName($status);
|
||||
|
||||
$item->setStatusIcon("{$status_icon} {$status_color}", $status_label);
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
|||
->setBuildablePHID($this->getPHID())
|
||||
->setBuildPlanPHID($plan->getPHID())
|
||||
->setBuildParameters($parameters)
|
||||
->setBuildStatus(HarbormasterBuild::STATUS_PENDING);
|
||||
->setBuildStatus(HarbormasterBuildStatus::STATUS_PENDING);
|
||||
if ($initiator_phid) {
|
||||
$build->setInitiatorPHID($initiator_phid);
|
||||
}
|
||||
|
|
|
@ -18,125 +18,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
private $buildTargets = self::ATTACHABLE;
|
||||
private $unprocessedCommands = self::ATTACHABLE;
|
||||
|
||||
/**
|
||||
* Not currently being built.
|
||||
*/
|
||||
const STATUS_INACTIVE = 'inactive';
|
||||
|
||||
/**
|
||||
* Pending pick up by the Harbormaster daemon.
|
||||
*/
|
||||
const STATUS_PENDING = 'pending';
|
||||
|
||||
/**
|
||||
* Current building the buildable.
|
||||
*/
|
||||
const STATUS_BUILDING = 'building';
|
||||
|
||||
/**
|
||||
* The build has passed.
|
||||
*/
|
||||
const STATUS_PASSED = 'passed';
|
||||
|
||||
/**
|
||||
* The build has failed.
|
||||
*/
|
||||
const STATUS_FAILED = 'failed';
|
||||
|
||||
/**
|
||||
* The build has aborted.
|
||||
*/
|
||||
const STATUS_ABORTED = 'aborted';
|
||||
|
||||
/**
|
||||
* The build encountered an unexpected error.
|
||||
*/
|
||||
const STATUS_ERROR = 'error';
|
||||
|
||||
/**
|
||||
* The build has been paused.
|
||||
*/
|
||||
const STATUS_PAUSED = 'paused';
|
||||
|
||||
/**
|
||||
* The build has been deadlocked.
|
||||
*/
|
||||
const STATUS_DEADLOCKED = 'deadlocked';
|
||||
|
||||
|
||||
/**
|
||||
* Get a human readable name for a build status constant.
|
||||
*
|
||||
* @param const Build status constant.
|
||||
* @return string Human-readable name.
|
||||
*/
|
||||
public static function getBuildStatusName($status) {
|
||||
$map = self::getBuildStatusMap();
|
||||
return idx($map, $status, pht('Unknown ("%s")', $status));
|
||||
}
|
||||
|
||||
public static function getBuildStatusMap() {
|
||||
return array(
|
||||
self::STATUS_INACTIVE => pht('Inactive'),
|
||||
self::STATUS_PENDING => pht('Pending'),
|
||||
self::STATUS_BUILDING => pht('Building'),
|
||||
self::STATUS_PASSED => pht('Passed'),
|
||||
self::STATUS_FAILED => pht('Failed'),
|
||||
self::STATUS_ABORTED => pht('Aborted'),
|
||||
self::STATUS_ERROR => pht('Unexpected Error'),
|
||||
self::STATUS_PAUSED => pht('Paused'),
|
||||
self::STATUS_DEADLOCKED => pht('Deadlocked'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getBuildStatusIcon($status) {
|
||||
switch ($status) {
|
||||
case self::STATUS_INACTIVE:
|
||||
case self::STATUS_PENDING:
|
||||
return PHUIStatusItemView::ICON_OPEN;
|
||||
case self::STATUS_BUILDING:
|
||||
return PHUIStatusItemView::ICON_RIGHT;
|
||||
case self::STATUS_PASSED:
|
||||
return PHUIStatusItemView::ICON_ACCEPT;
|
||||
case self::STATUS_FAILED:
|
||||
return PHUIStatusItemView::ICON_REJECT;
|
||||
case self::STATUS_ABORTED:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_ERROR:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_PAUSED:
|
||||
return PHUIStatusItemView::ICON_MINUS;
|
||||
case self::STATUS_DEADLOCKED:
|
||||
return PHUIStatusItemView::ICON_WARNING;
|
||||
default:
|
||||
return PHUIStatusItemView::ICON_QUESTION;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBuildStatusColor($status) {
|
||||
switch ($status) {
|
||||
case self::STATUS_INACTIVE:
|
||||
return 'dark';
|
||||
case self::STATUS_PENDING:
|
||||
case self::STATUS_BUILDING:
|
||||
return 'blue';
|
||||
case self::STATUS_PASSED:
|
||||
return 'green';
|
||||
case self::STATUS_FAILED:
|
||||
case self::STATUS_ABORTED:
|
||||
case self::STATUS_ERROR:
|
||||
case self::STATUS_DEADLOCKED:
|
||||
return 'red';
|
||||
case self::STATUS_PAUSED:
|
||||
return 'dark';
|
||||
default:
|
||||
return 'bluegrey';
|
||||
}
|
||||
}
|
||||
|
||||
public static function initializeNewBuild(PhabricatorUser $actor) {
|
||||
return id(new HarbormasterBuild())
|
||||
->setBuildStatus(self::STATUS_INACTIVE)
|
||||
->setBuildStatus(HarbormasterBuildStatus::STATUS_INACTIVE)
|
||||
->setBuildGeneration(0);
|
||||
}
|
||||
|
||||
|
@ -220,8 +104,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
}
|
||||
|
||||
public function isBuilding() {
|
||||
return $this->getBuildStatus() === self::STATUS_PENDING ||
|
||||
$this->getBuildStatus() === self::STATUS_BUILDING;
|
||||
return
|
||||
$this->getBuildStatus() === HarbormasterBuildStatus::STATUS_PENDING ||
|
||||
$this->getBuildStatus() === HarbormasterBuildStatus::STATUS_BUILDING;
|
||||
}
|
||||
|
||||
public function isAutobuild() {
|
||||
|
@ -285,11 +170,11 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
|
||||
public function isComplete() {
|
||||
switch ($this->getBuildStatus()) {
|
||||
case self::STATUS_PASSED:
|
||||
case self::STATUS_FAILED:
|
||||
case self::STATUS_ABORTED:
|
||||
case self::STATUS_ERROR:
|
||||
case self::STATUS_PAUSED:
|
||||
case HarbormasterBuildStatus::STATUS_PASSED:
|
||||
case HarbormasterBuildStatus::STATUS_FAILED:
|
||||
case HarbormasterBuildStatus::STATUS_ABORTED:
|
||||
case HarbormasterBuildStatus::STATUS_ERROR:
|
||||
case HarbormasterBuildStatus::STATUS_PAUSED:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -297,7 +182,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
}
|
||||
|
||||
public function isPaused() {
|
||||
return ($this->getBuildStatus() == self::STATUS_PAUSED);
|
||||
return ($this->getBuildStatus() == HarbormasterBuildStatus::STATUS_PAUSED);
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
|
|
|
@ -27,11 +27,11 @@ final class HarbormasterBuildStatusDatasource
|
|||
private function buildResults() {
|
||||
$results = array();
|
||||
|
||||
$status_map = HarbormasterBuild::getBuildStatusMap();
|
||||
$status_map = HarbormasterBuildStatus::getBuildStatusMap();
|
||||
foreach ($status_map as $value => $name) {
|
||||
$result = id(new PhabricatorTypeaheadResult())
|
||||
->setIcon(HarbormasterBuild::getBuildStatusIcon($value))
|
||||
->setColor(HarbormasterBuild::getBuildStatusColor($value))
|
||||
->setIcon(HarbormasterBuildStatus::getBuildStatusIcon($value))
|
||||
->setColor(HarbormasterBuildStatus::getBuildStatusColor($value))
|
||||
->setPHID($value)
|
||||
->setName($name)
|
||||
->addAttribute(pht('Status'));
|
||||
|
|
Loading…
Reference in a new issue