Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / step / HarbormasterWaitForPreviousBuildStepImplementation.php
blobcec25c6ad3f0d209517b50130c07191a3d911d33
1 <?php
3 final class HarbormasterWaitForPreviousBuildStepImplementation
4 extends HarbormasterBuildStepImplementation {
6 public function getName() {
7 return pht('Wait for Previous Commits to Build');
10 public function getGenericDescription() {
11 return pht(
12 'Wait for previous commits to finish building the current plan '.
13 'before continuing.');
16 public function getBuildStepGroupKey() {
17 return HarbormasterControlBuildStepGroup::GROUPKEY;
20 public function execute(
21 HarbormasterBuild $build,
22 HarbormasterBuildTarget $build_target) {
24 // We can only wait when building against commits.
25 $buildable = $build->getBuildable();
26 $object = $buildable->getBuildableObject();
27 if (!($object instanceof PhabricatorRepositoryCommit)) {
28 return;
31 // Block until all previous builds of the same build plan have
32 // finished.
33 $plan = $build->getBuildPlan();
34 $blockers = $this->getBlockers($object, $plan, $build);
36 if ($blockers) {
37 throw new PhabricatorWorkerYieldException(15);
41 private function getBlockers(
42 PhabricatorRepositoryCommit $commit,
43 HarbormasterBuildPlan $plan,
44 HarbormasterBuild $source) {
46 $call = new ConduitCall(
47 'diffusion.commitparentsquery',
48 array(
49 'commit' => $commit->getCommitIdentifier(),
50 'repository' => $commit->getRepository()->getPHID(),
51 ));
52 $call->setUser(PhabricatorUser::getOmnipotentUser());
53 $parents = $call->execute();
55 $parents = id(new DiffusionCommitQuery())
56 ->setViewer(PhabricatorUser::getOmnipotentUser())
57 ->withRepository($commit->getRepository())
58 ->withIdentifiers($parents)
59 ->execute();
61 $blockers = array();
63 $build_objects = array();
64 foreach ($parents as $parent) {
65 if (!$parent->isImported()) {
66 $blockers[] = pht('Commit %s', $parent->getCommitIdentifier());
67 } else {
68 $build_objects[] = $parent->getPHID();
72 if ($build_objects) {
73 $buildables = id(new HarbormasterBuildableQuery())
74 ->setViewer(PhabricatorUser::getOmnipotentUser())
75 ->withBuildablePHIDs($build_objects)
76 ->withManualBuildables(false)
77 ->execute();
78 $buildable_phids = mpull($buildables, 'getPHID');
80 if ($buildable_phids) {
81 $builds = id(new HarbormasterBuildQuery())
82 ->setViewer(PhabricatorUser::getOmnipotentUser())
83 ->withBuildablePHIDs($buildable_phids)
84 ->withBuildPlanPHIDs(array($plan->getPHID()))
85 ->execute();
87 foreach ($builds as $build) {
88 if (!$build->isComplete()) {
89 $blockers[] = pht('Build %d', $build->getID());
95 return $blockers;