mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-03-29 12:38:11 +01:00
Summary: Ref T13546. Show ongoing and failed builds more clearly in "arc land" output. Also rename "DisplayRef" (which is not a "Ref") to "RefView" with the goal of improving clarity, and let callers "build...()" it so they can add more status, etc., information. Get rid of "[DisplayRef|RefView]Interface". In theory, future refs (say, in Phabricator) might not do anything here, but every Ref just ends up implementing it. This could perhaps be subclassed more narrowly in the future if necessary. Test Plan: Ran "arc land", grepped for various symbols. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21352
102 lines
2.2 KiB
PHP
102 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class ArcanistBuildRef
|
|
extends ArcanistRef {
|
|
|
|
const HARDPOINT_BUILDPLANREF = 'ref.build.buildplanRef';
|
|
|
|
private $parameters;
|
|
|
|
protected function newHardpoints() {
|
|
return array(
|
|
$this->newHardpoint(self::HARDPOINT_BUILDPLANREF),
|
|
);
|
|
}
|
|
|
|
public function getRefDisplayName() {
|
|
return pht('Build %d', $this->getID());
|
|
}
|
|
|
|
public static function newFromConduit(array $parameters) {
|
|
$ref = new self();
|
|
$ref->parameters = $parameters;
|
|
return $ref;
|
|
}
|
|
|
|
public function getID() {
|
|
return idx($this->parameters, 'id');
|
|
}
|
|
|
|
public function getPHID() {
|
|
return idx($this->parameters, 'phid');
|
|
}
|
|
|
|
public function getName() {
|
|
return idxv($this->parameters, array('fields', 'name'));
|
|
}
|
|
|
|
protected function buildRefView(ArcanistRefView $view) {
|
|
$view
|
|
->setObjectName($this->getRefDisplayName())
|
|
->setTitle($this->getName());
|
|
}
|
|
|
|
public function getBuildPlanRef() {
|
|
return $this->getHardpoint(self::HARDPOINT_BUILDPLANREF);
|
|
}
|
|
|
|
public function getBuildablePHID() {
|
|
return idxv($this->parameters, array('fields', 'buildablePHID'));
|
|
}
|
|
|
|
public function getBuildPlanPHID() {
|
|
return idxv($this->parameters, array('fields', 'buildPlanPHID'));
|
|
}
|
|
|
|
public function getStatus() {
|
|
return idxv($this->parameters, array('fields', 'buildStatus', 'value'));
|
|
}
|
|
|
|
public function getStatusName() {
|
|
return idxv($this->parameters, array('fields', 'buildStatus', 'name'));
|
|
}
|
|
|
|
public function getStatusANSIColor() {
|
|
return idxv(
|
|
$this->parameters,
|
|
array('fields', 'buildStatus', 'color.ansi'));
|
|
}
|
|
|
|
public function isComplete() {
|
|
switch ($this->getStatus()) {
|
|
case 'passed':
|
|
case 'failed':
|
|
case 'aborted':
|
|
case 'error':
|
|
case 'deadlocked':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function isPassed() {
|
|
return ($this->getStatus() === 'passed');
|
|
}
|
|
|
|
public function getStatusSortVector() {
|
|
$status = $this->getStatus();
|
|
|
|
// For now, just sort passed builds first.
|
|
if ($this->isPassed()) {
|
|
$status_class = 1;
|
|
} else {
|
|
$status_class = 2;
|
|
}
|
|
|
|
return id(new PhutilSortVector())
|
|
->addInt($status_class)
|
|
->addString($status);
|
|
}
|
|
|
|
}
|