@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement Build Plan "Hold Drafts" behavior

Summary: Ref T13258. Makes the new "Hold Drafts" behavior actually work.

Test Plan:
- Created a build plan which does "Make HTTP Request" somewhere random and then waits for a message.
- Created a Herald rule which "Always" runs this plan.
- Created revisions, loaded them, then sent their build targets a "fail" message a short time later.
- With "Always": Current behavior. Revision was held as a draft while building, and returned to me for changes when the build failed.
- With "If Building": Revision was held as a draft while building, but promoted once the build failed.
- With "Never": Revision promoted immediately, ignoring the build completely.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13258

Differential Revision: https://secure.phabricator.com/D20232

+45 -5
+36 -1
src/applications/differential/storage/DifferentialRevision.php
··· 877 877 PhabricatorUser $viewer, 878 878 array $phids) { 879 879 880 - return id(new HarbormasterBuildQuery()) 880 + $builds = id(new HarbormasterBuildQuery()) 881 881 ->setViewer($viewer) 882 882 ->withBuildablePHIDs($phids) 883 883 ->withAutobuilds(false) ··· 893 893 HarbormasterBuildStatus::STATUS_DEADLOCKED, 894 894 )) 895 895 ->execute(); 896 + 897 + // Filter builds based on the "Hold Drafts" behavior of their associated 898 + // build plans. 899 + 900 + $hold_drafts = HarbormasterBuildPlanBehavior::BEHAVIOR_DRAFTS; 901 + $behavior = HarbormasterBuildPlanBehavior::getBehavior($hold_drafts); 902 + 903 + $key_never = HarbormasterBuildPlanBehavior::DRAFTS_NEVER; 904 + $key_building = HarbormasterBuildPlanBehavior::DRAFTS_IF_BUILDING; 905 + 906 + foreach ($builds as $key => $build) { 907 + $plan = $build->getBuildPlan(); 908 + $hold_key = $behavior->getPlanOption($plan)->getKey(); 909 + 910 + $hold_never = ($hold_key === $key_never); 911 + $hold_building = ($hold_key === $key_building); 912 + 913 + // If the build "Never" holds drafts from promoting, we don't care what 914 + // the status is. 915 + if ($hold_never) { 916 + unset($builds[$key]); 917 + continue; 918 + } 919 + 920 + // If the build holds drafts from promoting "While Building", we only 921 + // care about the status until it completes. 922 + if ($hold_building) { 923 + if ($build->isComplete()) { 924 + unset($builds[$key]); 925 + continue; 926 + } 927 + } 928 + } 929 + 930 + return $builds; 896 931 } 897 932 898 933
+9 -4
src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php
··· 17 17 const RESTARTABLE_ALWAYS = 'always'; 18 18 const RESTARTABLE_NEVER = 'never'; 19 19 20 + const BEHAVIOR_DRAFTS = 'hold-drafts'; 21 + const DRAFTS_ALWAYS = 'always'; 22 + const DRAFTS_IF_BUILDING = 'building'; 23 + const DRAFTS_NEVER = 'never'; 24 + 20 25 public function setKey($key) { 21 26 $this->key = $key; 22 27 return $this; ··· 138 143 public static function newPlanBehaviors() { 139 144 $draft_options = array( 140 145 id(new HarbormasterBuildPlanBehaviorOption()) 141 - ->setKey('always') 146 + ->setKey(self::DRAFTS_ALWAYS) 142 147 ->setIcon('fa-check-circle-o green') 143 148 ->setName(pht('Always')) 144 149 ->setIsDefault(true) ··· 147 152 'Revisions are not sent for review until the build completes, '. 148 153 'and are returned to the author for updates if the build fails.')), 149 154 id(new HarbormasterBuildPlanBehaviorOption()) 150 - ->setKey('building') 155 + ->setKey(self::DRAFTS_IF_BUILDING) 151 156 ->setIcon('fa-pause-circle-o yellow') 152 157 ->setName(pht('If Building')) 153 158 ->setDescription( ··· 155 160 'Revisions are not sent for review until the build completes, '. 156 161 'but they will be sent for review even if it fails.')), 157 162 id(new HarbormasterBuildPlanBehaviorOption()) 158 - ->setKey('never') 163 + ->setKey(self::DRAFTS_NEVER) 159 164 ->setIcon('fa-circle-o red') 160 165 ->setName(pht('Never')) 161 166 ->setDescription( ··· 262 267 263 268 $behaviors = array( 264 269 id(new self()) 265 - ->setKey('hold-drafts') 270 + ->setKey(self::BEHAVIOR_DRAFTS) 266 271 ->setName(pht('Hold Drafts')) 267 272 ->setEditInstructions( 268 273 pht(