Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuild.php
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | final class HarbormasterBuild extends HarbormasterDAO | ||||
public function isPaused() { | public function isPaused() { | ||||
return $this->getBuildStatusObject()->isPaused(); | return $this->getBuildStatusObject()->isPaused(); | ||||
} | } | ||||
public function isPassed() { | public function isPassed() { | ||||
return $this->getBuildStatusObject()->isPassed(); | return $this->getBuildStatusObject()->isPassed(); | ||||
} | } | ||||
public function isFailed() { | |||||
return $this->getBuildStatusObject()->isFailed(); | |||||
} | |||||
public function getURI() { | public function getURI() { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
return "/harbormaster/build/{$id}/"; | return "/harbormaster/build/{$id}/"; | ||||
} | } | ||||
protected function getBuildStatusObject() { | protected function getBuildStatusObject() { | ||||
$status_key = $this->getBuildStatus(); | $status_key = $this->getBuildStatus(); | ||||
return HarbormasterBuildStatus::newBuildStatusObject($status_key); | return HarbormasterBuildStatus::newBuildStatusObject($status_key); | ||||
Show All 12 Lines | /* -( Build Commands )----------------------------------------------------- */ | ||||
} | } | ||||
public function attachUnprocessedCommands(array $commands) { | public function attachUnprocessedCommands(array $commands) { | ||||
$this->unprocessedCommands = $commands; | $this->unprocessedCommands = $commands; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function canRestartBuild() { | public function canRestartBuild() { | ||||
if ($this->isAutobuild()) { | try { | ||||
$this->assertCanRestartBuild(); | |||||
return true; | |||||
} catch (HarbormasterRestartException $ex) { | |||||
return false; | return false; | ||||
} | } | ||||
} | |||||
public function assertCanRestartBuild() { | |||||
if ($this->isAutobuild()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Can Not Restart Autobuild'), | |||||
pht( | |||||
'This build can not be restarted because it is an automatic '. | |||||
'build.')); | |||||
} | |||||
$restartable = HarbormasterBuildPlanBehavior::BEHAVIOR_RESTARTABLE; | |||||
$plan = $this->getBuildPlan(); | $plan = $this->getBuildPlan(); | ||||
if (!$plan->canRestartBuildPlan()) { | |||||
return false; | $option = HarbormasterBuildPlanBehavior::getBehavior($restartable) | ||||
->getPlanOption($plan); | |||||
$option_key = $option->getKey(); | |||||
$never_restartable = HarbormasterBuildPlanBehavior::RESTARTABLE_NEVER; | |||||
$is_never = ($option_key === $never_restartable); | |||||
if ($is_never) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Build Plan Prevents Restart'), | |||||
pht( | |||||
'This build can not be restarted because the build plan is '. | |||||
'configured to prevent the build from restarting.')); | |||||
} | } | ||||
return !$this->isRestarting(); | $failed_restartable = HarbormasterBuildPlanBehavior::RESTARTABLE_IF_FAILED; | ||||
$is_failed = ($option_key === $failed_restartable); | |||||
if ($is_failed) { | |||||
if (!$this->isFailed()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Only Restartable if Failed'), | |||||
pht( | |||||
'This build can not be restarted because the build plan is '. | |||||
'configured to prevent the build from restarting unless it '. | |||||
'has failed, and it has not failed.')); | |||||
} | |||||
} | |||||
if ($this->isRestarting()) { | |||||
throw new HarbormasterRestartException( | |||||
pht('Already Restarting'), | |||||
pht( | |||||
'This build is already restarting. You can not reissue a restart '. | |||||
'command to a restarting build.')); | |||||
} | |||||
} | } | ||||
public function canPauseBuild() { | public function canPauseBuild() { | ||||
if ($this->isAutobuild()) { | if ($this->isAutobuild()) { | ||||
return false; | return false; | ||||
} | } | ||||
return !$this->isComplete() && | return !$this->isComplete() && | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |