Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15405234
D20232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D20232.diff
View Options
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -877,7 +877,7 @@
PhabricatorUser $viewer,
array $phids) {
- return id(new HarbormasterBuildQuery())
+ $builds = id(new HarbormasterBuildQuery())
->setViewer($viewer)
->withBuildablePHIDs($phids)
->withAutobuilds(false)
@@ -893,6 +893,41 @@
HarbormasterBuildStatus::STATUS_DEADLOCKED,
))
->execute();
+
+ // Filter builds based on the "Hold Drafts" behavior of their associated
+ // build plans.
+
+ $hold_drafts = HarbormasterBuildPlanBehavior::BEHAVIOR_DRAFTS;
+ $behavior = HarbormasterBuildPlanBehavior::getBehavior($hold_drafts);
+
+ $key_never = HarbormasterBuildPlanBehavior::DRAFTS_NEVER;
+ $key_building = HarbormasterBuildPlanBehavior::DRAFTS_IF_BUILDING;
+
+ foreach ($builds as $key => $build) {
+ $plan = $build->getBuildPlan();
+ $hold_key = $behavior->getPlanOption($plan)->getKey();
+
+ $hold_never = ($hold_key === $key_never);
+ $hold_building = ($hold_key === $key_building);
+
+ // If the build "Never" holds drafts from promoting, we don't care what
+ // the status is.
+ if ($hold_never) {
+ unset($builds[$key]);
+ continue;
+ }
+
+ // If the build holds drafts from promoting "While Building", we only
+ // care about the status until it completes.
+ if ($hold_building) {
+ if ($build->isComplete()) {
+ unset($builds[$key]);
+ continue;
+ }
+ }
+ }
+
+ return $builds;
}
diff --git a/src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php b/src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php
--- a/src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php
+++ b/src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php
@@ -17,6 +17,11 @@
const RESTARTABLE_ALWAYS = 'always';
const RESTARTABLE_NEVER = 'never';
+ const BEHAVIOR_DRAFTS = 'hold-drafts';
+ const DRAFTS_ALWAYS = 'always';
+ const DRAFTS_IF_BUILDING = 'building';
+ const DRAFTS_NEVER = 'never';
+
public function setKey($key) {
$this->key = $key;
return $this;
@@ -138,7 +143,7 @@
public static function newPlanBehaviors() {
$draft_options = array(
id(new HarbormasterBuildPlanBehaviorOption())
- ->setKey('always')
+ ->setKey(self::DRAFTS_ALWAYS)
->setIcon('fa-check-circle-o green')
->setName(pht('Always'))
->setIsDefault(true)
@@ -147,7 +152,7 @@
'Revisions are not sent for review until the build completes, '.
'and are returned to the author for updates if the build fails.')),
id(new HarbormasterBuildPlanBehaviorOption())
- ->setKey('building')
+ ->setKey(self::DRAFTS_IF_BUILDING)
->setIcon('fa-pause-circle-o yellow')
->setName(pht('If Building'))
->setDescription(
@@ -155,7 +160,7 @@
'Revisions are not sent for review until the build completes, '.
'but they will be sent for review even if it fails.')),
id(new HarbormasterBuildPlanBehaviorOption())
- ->setKey('never')
+ ->setKey(self::DRAFTS_NEVER)
->setIcon('fa-circle-o red')
->setName(pht('Never'))
->setDescription(
@@ -262,7 +267,7 @@
$behaviors = array(
id(new self())
- ->setKey('hold-drafts')
+ ->setKey(self::BEHAVIOR_DRAFTS)
->setName(pht('Hold Drafts'))
->setEditInstructions(
pht(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 10:50 AM (4 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223883
Default Alt Text
D20232.diff (3 KB)
Attached To
Mode
D20232: Implement Build Plan "Hold Drafts" behavior
Attached
Detach File
Event Timeline
Log In to Comment